Logging is here!

Environment

Definition

An environment is a first class dimension that you use to scope an entire Datadog APM application. Some display settings can be shared across environments, but all the measurable data (traces/metrics/statistics) can not be re-aggregated across multiple environments. Use cases include:

  • Stage environments such as production, staging, and pre-production
  • Data centers and availability zones in isolation

Environments are tags, therefore they must follow the following rules:

  • They must start with a lower case letter.
  • Other characters must be alphanumeric lower case Unicode characters, underscores, minuses, colons, periods or slashes.
  • They must not be more than 100 characters long.

Environments in traces and configuration files are normalized:

  • Unsupported characters are replaced by underscores.
  • Upper case characters are converted to lower case.

Default environment

The default environment for un-tagged data is env:none. See below to see how to specify custom environments:

Setup

There are several ways to specify an environment when reporting data:

  1. Host tag:
    Use a host tag with the format env:XXXX to tag all traces from that Agent accordingly.

  2. Agent configuration:
    Override the default tag used by the trace Agent in the Agent configuration file. This tags all traces coming through the Agent, overriding the host tag value.

    [trace.config]
    env = pre-prod
    
  3. Per trace:
    When submitting a single trace, specify an environment by tagging one of its spans with the metadata key env. This overrides the Agent configuration and the host tags value (if any).

    • Go:

      tracer.SetMeta(“env”, “prod”)
      

      For OpenTracing use the “GlobalTags” field in the “opentracing.Configuration” structure.

    • Java:
      Via sysprop:

      -Ddd.trace.span.tags=”env:prod”
      

      Via env var:

      DD_TRACE_SPAN_TAGS=”env:prod”
      
    • Ruby:

      Datadog.tracer.set_tags(‘env’ => ‘prod’)
      
    • Python:

      from ddtrace import tracer
      tracer.set_tags('env', 'prod')
      

Further Reading