> For the complete documentation index, see [llms.txt](https://docs.dorg.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dorg.pro/create-competency/develop-a-competency/mcp-server/logging-via-open-telemetry.md).

# Logging via Open Telemetry

The MCP container is invited to use **Open Telemetry** for logging.

The usage of the Dorg Open Telemetry ensure the retention policies related to log data, as configured by the administrator, can be honored automatically.

Your Docker container will receive the OTEL endpoint via the standard environment variables:

* `OTEL_EXPORTER_OTLP_ENDPOINT`
* `OTEL_EXPORTER_OTLP_HEADERS` *(optional — will be omitted when not required)*
* `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT`
* `OTEL_SERVICE_NAME`

Also set the following OTEL fields properly when you send your log and metrics:

* `service.version = <competency_version>` (resource, at SDK startup)
* `tool.name = <tool_name>` (log attribute, on every tool-call log line)

`tool.name` on tool-call logs lets Dorg apply per-tool log retention from your manifest (`tools[].retention.log_retention_hours`). Retention is enforced by the orchestrator. `service.name` is set automatically by the OTEL SDK from `OTEL_SERVICE_NAME`.

Here a brief example in Node.js about how to set these properties at runtime:

```javascript
const { logs } = require('@opentelemetry/api-logs');
const { Resource } = require('@opentelemetry/resources');
const {
  ATTR_SERVICE_NAME,
  ATTR_SERVICE_VERSION,
} = require('@opentelemetry/semantic-conventions');

// ENV Injected by Dorg at deploy time
const serviceName = process.env.OTEL_SERVICE_NAME;

// From your skill manifest (bake at build time)
const competencyVersion = '1.4.2';

// Initialize SDK/exporter once at startup (sketch):
//   const resource = Resource.default().merge(new Resource({
//     [ATTR_SERVICE_NAME]: serviceName,
//     [ATTR_SERVICE_VERSION]: competencyVersion,
//   }));
//   // Exporter reads OTEL_EXPORTER_OTLP_* env vars (endpoints, headers, protocol)

const logger = logs.getLogger('mcp', competencyVersion);
function log(toolName, message) {
  logger.emit({
    severityText: 'INFO',
    body: message,
    attributes: {
      'tool.name': toolName,
    },
  });
}
// usage
log('list_repositories', 'start');
log('list_repositories', 'done');
```

For `service.version` and `tool.name` use the same values as they are set in the [Manifest](/create-competency/develop-a-competency/write-the-competency-manifest.md) file.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.dorg.pro/create-competency/develop-a-competency/mcp-server/logging-via-open-telemetry.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
