Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

## [Unreleased]

## [1.21.0] - 2026-11-17

Packages: `runtime-node` 1.17.0, and the Python adapter (`adapters/python`, copied, not published). The other packages are unchanged; the `otlp-ingester` README is updated without a release.

### The environment is sent as `deployment.environment.name`

OpenTelemetry's semantic conventions renamed the resource attribute `deployment.environment` to `deployment.environment.name`. Every Autter ingester version reads both and prefers the new name, so nothing changes in Autter.

- `runtime-node`: `initAutterServer` sends the environment on spans and metrics as `deployment.environment.name` (log records already did). A value set in `OTEL_RESOURCE_ATTRIBUTES` still wins, under either name: one under the old name is also sent as `deployment.environment.name`, so it keeps winning now that the SDK no longer sends the old name itself. `npx @autter/runtime-node verify` sends its test event with the new name.
- Python adapter: under a test runner, `init_tracing()` sets `deployment.environment.name=test` (was `deployment.environment=test`) when the resource has no environment; an environment the service sets, under either name, still wins and is left as it is. The test event of `python3 compat.py verify` uses the new name.
- Docs and examples set `OTEL_RESOURCE_ATTRIBUTES=…,deployment.environment.name=…`. `deployment.environment` still works.
- **Behaviour change:** a collector or backend of your own that reads `deployment.environment` from Autter's Node spans, or from the Python adapter's test environment, should read `deployment.environment.name` (or both).

## [1.20.1] - 2026-11-15

Packages: `runtime-browser` 1.8.2, `runtime-node` 1.16.1, `runtime-edge` 1.4.3, `runtime-next` 1.11.1, `runtime-cli` 1.4.1, `otlp-ingester` 1.18.1. No code changes from 1.20.0.
Expand Down
10 changes: 5 additions & 5 deletions adapters/python/autter_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
Test runs, commit and release. :func:`init_tracing` fills in three resource
attributes the service did not set itself (an explicit value always wins):

* ``deployment.environment = test`` when the process runs under a test
* ``deployment.environment.name = test`` when the process runs under a test
runner (pytest, or Django's ``manage.py test``) and the resource has no
environment at all (neither ``deployment.environment.name`` nor
``deployment.environment``). Off with ``AUTTER_DETECT_TEST_ENV=false`` or
Expand Down Expand Up @@ -670,10 +670,10 @@ def _with_deployment(resource: Resource, detect_test_env: Optional[bool], detect
if detect_test_env if detect_test_env is not None else _env_flag(DETECT_TEST_ENV_ENV, True):
runner = detect_test_runner()
if runner is not None:
added["deployment.environment"] = _TEST_ENVIRONMENT
added["deployment.environment.name"] = _TEST_ENVIRONMENT
LOGGER.info(
"[autter-runtime] test run detected (%s): reporting deployment.environment=test. Set "
"deployment.environment, or AUTTER_DETECT_TEST_ENV=false, to report another environment.",
"[autter-runtime] test run detected (%s): reporting deployment.environment.name=test. Set "
"deployment.environment.name, or AUTTER_DETECT_TEST_ENV=false, to report another environment.",
runner,
)
if _has_value(attributes, _COMMIT_ATTRIBUTE):
Expand Down Expand Up @@ -886,7 +886,7 @@ def init_tracing(
``False`` turns it off): under a test runner (:func:`detect_test_runner`:
pytest, Django's ``manage.py test``), a resource with neither
``deployment.environment.name`` nor ``deployment.environment`` gets
``deployment.environment=test``, logged once at info level.
``deployment.environment.name=test``, logged once at info level.
* ``deployment.commit``: the running commit, :func:`detect_commit` (the
first of :data:`COMMIT_ENV_VARS` holding 7 to 40 hexadecimal
characters; environment variables only), when the resource has none.
Expand Down
2 changes: 1 addition & 1 deletion adapters/python/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ def add(step: str, status: str, detail: str, fix: Optional[str] = None) -> None:
return done()
add("auth", "pass", "key accepted")

resource = {"attributes": [_attr("service.name", service), _attr("deployment.environment", environment),
resource = {"attributes": [_attr("service.name", service), _attr("deployment.environment.name", environment),
*([_attr("service.version", release)] if release else []),
_attr("autter.verify.id", trace_id)]}
end = time.time_ns()
Expand Down
17 changes: 11 additions & 6 deletions adapters/python/test_deployment_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,16 @@ class TestEnvironment(unittest.TestCase):
def test_a_test_run_without_an_environment_reports_test_and_says_so_once(self):
with self.assertLogs("autter.runtime", "INFO") as logs:
resource = _resource(runner="pytest")
self.assertEqual(resource["deployment.environment"], "test")
self.assertEqual(resource["deployment.environment.name"], "test")
self.assertNotIn("deployment.environment", resource, "only the current semantic-conventions name")
lines = [line for line in logs.output if "test run detected" in line]
self.assertEqual(len(lines), 1)
self.assertIn("INFO", lines[0])
self.assertIn("pytest", lines[0])

def test_a_passed_resource_without_an_environment_also_reports_test(self):
resource = _resource(runner="manage.py test", resource=Resource.create({"service.name": "shop"}))
self.assertEqual(resource["deployment.environment"], "test")
self.assertEqual(resource["deployment.environment.name"], "test")
self.assertEqual(resource["service.name"], "shop")

def test_an_explicit_environment_always_wins(self):
Expand Down Expand Up @@ -196,11 +197,13 @@ def test_opt_outs(self):
({"AUTTER_DETECT_TEST_ENV": "true"}, {"detect_test_env": False}), # the argument wins
):
with self.subTest(env=env, kwargs=kwargs):
self.assertNotIn("deployment.environment", _resource(env, runner="pytest", **kwargs))
resource = _resource(env, runner="pytest", **kwargs)
self.assertNotIn("deployment.environment.name", resource)
self.assertNotIn("deployment.environment", resource)
# And the argument turns it on over the variable.
self.assertEqual(
_resource({"AUTTER_DETECT_TEST_ENV": "false"}, runner="pytest", detect_test_env=True)[
"deployment.environment"
"deployment.environment.name"
],
"test",
)
Expand All @@ -215,7 +218,7 @@ def test_request_counts_carry_the_same_environment_commit_and_release(self):
provider.shutdown()
metric_resources = metric_exporter.resources()
self.assertTrue(metric_resources, "the request was counted")
for key, value in (("deployment.environment", "test"), ("deployment.commit", SHA), ("service.version", SHA)):
for key, value in (("deployment.environment.name", "test"), ("deployment.commit", SHA), ("service.version", SHA)):
self.assertEqual(provider.resource.attributes[key], value)
for metric_resource in metric_resources: # older SDKs export once more on shutdown
self.assertEqual(metric_resource[key], value)
Expand Down Expand Up @@ -421,12 +424,14 @@ def test_init_tracing_marks_retained_error_spans(self):

def test_reports_test():
provider = init_tracing(exporter=InMemorySpanExporter(), set_global=False, count_requests=False)
assert provider.resource.attributes["deployment.environment"] == "test"
assert provider.resource.attributes["deployment.environment.name"] == "test"
assert "deployment.environment" not in provider.resource.attributes

def test_explicit_environment_wins():
os.environ["OTEL_RESOURCE_ATTRIBUTES"] = "deployment.environment=production"
provider = init_tracing(exporter=InMemorySpanExporter(), set_global=False, count_requests=False)
assert provider.resource.attributes["deployment.environment"] == "production"
assert "deployment.environment.name" not in provider.resource.attributes # the old name, set by the user, is kept and wins
"""
)

Expand Down
3 changes: 2 additions & 1 deletion adapters/python/test_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ def test_every_step_passes(self):
[(path, body)] = state["posted"][:1]
attrs = {a["key"]: a["value"]["stringValue"] for a in body["resourceSpans"][0]["resource"]["attributes"]}
self.assertEqual(attrs["autter.verify.id"], report["traceId"])
self.assertEqual(attrs["deployment.environment"], "verify")
self.assertEqual(attrs["deployment.environment.name"], "verify")
self.assertNotIn("deployment.environment", attrs)
finally:
server.shutdown()

Expand Down
4 changes: 2 additions & 2 deletions docs/GETTING-STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ package at all — configure the SDK you already use:
OTEL_EXPORTER_OTLP_ENDPOINT=https://your-ingester.example.com
OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer ${AUTTER_RUNTIME_KEY}"
OTEL_SERVICE_NAME=payments-api
OTEL_RESOURCE_ATTRIBUTES=service.version=${GIT_SHA},deployment.commit=${GIT_SHA},deployment.environment=production
OTEL_RESOURCE_ATTRIBUTES=service.version=${GIT_SHA},deployment.commit=${GIT_SHA},deployment.environment.name=production
OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=0.01
```
Expand Down Expand Up @@ -526,7 +526,7 @@ reports, `test`:
| --- | --- | --- |
| `@autter/runtime-node` (and `@autter/runtime-next` on the server) | Jest, Vitest or `node --test`, with no `environment` option and no `NODE_ENV` | pass `environment` or set `NODE_ENV` |
| `autter_tracing.py` | pytest or Django's `manage.py test`, with no environment on the resource | `AUTTER_DETECT_TEST_ENV=false` or `init_tracing(detect_test_env=False)` |
| Any other OpenTelemetry SDK | set it yourself, e.g. `OTEL_RESOURCE_ATTRIBUTES=deployment.environment=test` in the CI job | |
| Any other OpenTelemetry SDK | set it yourself, e.g. `OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=test` in the CI job | |

An explicit environment always wins. Autter leaves the `test` environment
out of its default views and never pages on it. The ingester never changes
Expand Down
10 changes: 5 additions & 5 deletions docs/INTEGRATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ Configuration is environment variables only:
OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.autter.dev # the exporter adds /v1/traces
OTEL_EXPORTER_OTLP_HEADERS=x-autter-key=${AUTTER_RUNTIME_KEY} # the server key
OTEL_SERVICE_NAME=shop
OTEL_RESOURCE_ATTRIBUTES=service.version=${GIT_SHA},deployment.environment=production
OTEL_RESOURCE_ATTRIBUTES=service.version=${GIT_SHA},deployment.environment.name=production
OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=0.01 # 1% of healthy traces; init_tracing() exports every error
AUTTER_COUNT_REQUESTS=true # count every request (the default; older copies need it set)
Expand All @@ -250,11 +250,11 @@ always wins:
or `init_tracing(detect_release=False)` turns the release default off; the
commit is still sent.
- **Test runs.** Running your tests with tracing on? Under pytest or
`manage.py test`, the adapter reports `deployment.environment=test` unless
`manage.py test`, the adapter reports `deployment.environment.name=test` unless
you set an environment yourself; set `AUTTER_DETECT_TEST_ENV=false` (or
`init_tracing(detect_test_env=False)`) to turn this off. An environment in
`OTEL_RESOURCE_ATTRIBUTES` counts as set, so keep
`deployment.environment=production` out of the environment your tests run
`deployment.environment.name=production` out of the environment your tests run
in. Autter leaves `test` out of default views and never pages on it.
- Requests made through Starlette's or FastAPI's `TestClient`, or Django's
test `Client` when the instrumentation records its host `testserver`, get
Expand Down Expand Up @@ -581,7 +581,7 @@ exp, _ := otlptracehttp.New(ctx,
"authorization": "Bearer " + os.Getenv("AUTTER_RUNTIME_KEY"),
}),
)
// resource: service.name, service.version (release), deployment.environment
// resource: service.name, service.version (release), deployment.environment.name
// errors: span.RecordError(err); span.SetStatus(codes.Error, err.Error())
```

Expand Down Expand Up @@ -611,7 +611,7 @@ OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.autter.dev
OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer ${AUTTER_RUNTIME_KEY}"
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_SERVICE_NAME=payments-api
OTEL_RESOURCE_ATTRIBUTES=service.version=${GIT_SHA},deployment.environment=production
OTEL_RESOURCE_ATTRIBUTES=service.version=${GIT_SHA},deployment.environment.name=production
OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=0.01
```
Expand Down
2 changes: 1 addition & 1 deletion docs/WITHOUT-NPM.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.autter.dev
OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer ${AUTTER_RUNTIME_KEY}"
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_SERVICE_NAME=payments-api
OTEL_RESOURCE_ATTRIBUTES=service.version=${GIT_SHA},deployment.environment=production
OTEL_RESOURCE_ATTRIBUTES=service.version=${GIT_SHA},deployment.environment.name=production
OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=0.01
```
Expand Down
2 changes: 1 addition & 1 deletion examples/python/django/shop/observability.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.autter.dev
OTEL_EXPORTER_OTLP_HEADERS=x-autter-key=${AUTTER_RUNTIME_KEY}
OTEL_SERVICE_NAME=shop
OTEL_RESOURCE_ATTRIBUTES=service.version=${GIT_SHA},deployment.environment=production
OTEL_RESOURCE_ATTRIBUTES=service.version=${GIT_SHA},deployment.environment.name=production
OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=0.1
"""
Expand Down
2 changes: 1 addition & 1 deletion examples/python/django/test_django_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_unsampled_traffic_still_exports_every_error(self):
self.assertIs(span["attributes"]["autter.tail_retained"], True)
self.assertEqual(span["resource"]["service.name"], SERVICE)
self.assertEqual(span["resource"]["service.version"], RELEASE)
self.assertEqual(span["resource"]["deployment.environment"], "test")
self.assertEqual(span["resource"]["deployment.environment.name"], "test")
self.assertEqual(self.stub.trace_requests()[0]["headers"].get("x-autter-key"), TEST_KEY)

# Unhandled → Django's 500: DjangoInstrumentor records it on the
Expand Down
2 changes: 1 addition & 1 deletion examples/python/testing/compose_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def readme_env(service: str, extra: dict | None = None) -> dict:
"OTEL_EXPORTER_OTLP_ENDPOINT": INGESTER,
"OTEL_EXPORTER_OTLP_HEADERS": f"x-autter-key={LOCAL_DEV_KEY}",
"OTEL_SERVICE_NAME": service,
"OTEL_RESOURCE_ATTRIBUTES": f"service.version={RUN},deployment.environment=development",
"OTEL_RESOURCE_ATTRIBUTES": f"service.version={RUN},deployment.environment.name=development",
"OTEL_TRACES_SAMPLER": "parentbased_traceidratio",
"OTEL_TRACES_SAMPLER_ARG": "0.1",
"OTEL_BSP_SCHEDULE_DELAY": "200",
Expand Down
2 changes: 1 addition & 1 deletion examples/python/testing/otlp_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def recipe_env(stub: OtlpStub, service: str, *, ratio: str = "0", extra: Optiona
"OTEL_EXPORTER_OTLP_HEADERS": f"x-autter-key={TEST_KEY}",
"OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
"OTEL_SERVICE_NAME": service,
"OTEL_RESOURCE_ATTRIBUTES": f"service.version={RELEASE},deployment.environment=test",
"OTEL_RESOURCE_ATTRIBUTES": f"service.version={RELEASE},deployment.environment.name=test",
"OTEL_TRACES_SAMPLER": "parentbased_traceidratio",
"OTEL_TRACES_SAMPLER_ARG": ratio,
# Tests only: export quickly instead of every 5 s.
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/otlp-ingester/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ off by default, and the salt should be kept and rotated like any secret.

## Test traffic (1.18.0)

Test traffic is separated by setting `deployment.environment=test` in the
test run. The Python adapter and `@autter/runtime-node` do this themselves
Test traffic is separated by setting `deployment.environment.name=test` in
the test run (the deprecated `deployment.environment` is still read). The Python adapter and `@autter/runtime-node` do this themselves
under a test runner from the next release; anything else sets it in
`OTEL_RESOURCE_ATTRIBUTES`. The ingester never changes the environment
because of what a request says about itself (its user agent, its host, its
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@autter/runtime-node",
"version": "1.16.1",
"version": "1.17.0",
"description": "Autter Runtime for Node.js: request wide events, coded errors, operation logging, same-origin browser relay and a curated OpenTelemetry server tracker",
"license": "MIT",
"type": "module",
Expand Down
36 changes: 36 additions & 0 deletions packages/runtime-node/src/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,39 @@ export function testRunnerDetected(env: Env = process.env): boolean {
export function resolveEnvironment(environment: string | undefined, env: Env = process.env): string {
return environment ?? env.NODE_ENV ?? (testRunnerDetected(env) ? "test" : "production");
}

/** OpenTelemetry's resource attribute for the environment (semantic conventions 1.27+). */
export const ENVIRONMENT_ATTRIBUTE = "deployment.environment.name";
/** The deprecated name it replaced; still read where a user sets it. */
export const LEGACY_ENVIRONMENT_ATTRIBUTE = "deployment.environment";

/**
* The environment a user set in `OTEL_RESOURCE_ATTRIBUTES` (comma-separated
* `key=value`, values percent-encoded per the OpenTelemetry spec):
* `deployment.environment.name`, else the deprecated `deployment.environment`.
* Undefined when neither is set.
*
* The NodeSDK merges those attributes over the SDK's own resource, so a value
* set there has always been the environment spans report. Now that the SDK
* sends `deployment.environment.name`, a value under the old name would sit
* beside it and lose (the ingester prefers the new name); the SDK sends it
* under the new name instead, so it keeps winning.
*/
export function environmentFromResourceAttributes(env: Env = process.env): string | undefined {
const raw = env.OTEL_RESOURCE_ATTRIBUTES;
if (!raw) return undefined;
const pairs = new Map<string, string>();
for (const part of raw.split(",")) {
const at = part.indexOf("=");
if (at <= 0) continue;
const key = part.slice(0, at).trim();
let value = part.slice(at + 1).trim();
try {
value = decodeURIComponent(value);
} catch {
// Not percent-encoded as the spec asks: kept as written.
}
if (key && value) pairs.set(key, value);
}
return pairs.get(ENVIRONMENT_ATTRIBUTE) ?? pairs.get(LEGACY_ENVIRONMENT_ATTRIBUTE);
}
7 changes: 5 additions & 2 deletions packages/runtime-node/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import { authHeaders, resolveIngestKey, warnKeyKind, warnMissingKey } from "./in
import { IngestMetricExporter, IngestSpanExporter } from "./ingest-exporters.js";
import { makeUrlQueryPolicy } from "./url-query.js";
import { startMemoryMetrics } from "./memory.js";
import { detectCommit, resolveEnvironment, resolveRelease } from "./deployment.js";
import { detectCommit, ENVIRONMENT_ATTRIBUTE, environmentFromResourceAttributes, resolveEnvironment, resolveRelease } from "./deployment.js";
import {
configureExportErrors,
exportErrorMark,
Expand Down Expand Up @@ -1385,7 +1385,10 @@ export function initAutterServer(options: AutterServerOptions): AutterServer {
"service.instance.id": (options.instanceId || process.env.AUTTER_RUNTIME_INSTANCE_ID || randomUUID()).slice(0, 128),
...(release ? { [ATTR_SERVICE_VERSION]: release } : {}),
...(commit ? { "deployment.commit": commit } : {}),
"deployment.environment": environment,
// The current semantic-conventions name (log records already used it). A
// value set in OTEL_RESOURCE_ATTRIBUTES, under either name, still wins:
// the NodeSDK merges those over this resource.
[ENVIRONMENT_ATTRIBUTE]: environmentFromResourceAttributes() ?? environment,
// OTel semconv for SDK distributions: the ingester records which
// Autter SDK version each service runs (version compatibility checks).
"telemetry.distro.name": distro.name,
Expand Down
Loading
Loading