8 January 2024

Adding deployment environment to Grafana Faro traces

One of the great things about OpenTelemetry is the standardisation of span attributes and resource attributes.
An example of this is deployment.environment.

Attribute Type Description Examples Requirement Level
deployment.environment string Name of the deployment environment (aka deployment tier). staging; production Recommended

Source: https://opentelemetry.io/docs/specs/semconv/resource/deployment-environment/

With Grafana Faro you can configure the environment, as I explained in my blog post about the setup of Grafana Faro. This adds environment to the setup. In my technical deep dive blog post I explained that the data is sent as logs and as traces. The logs include the environment attribute which you can find as app_environment attribute. But the information is not available in the traces stored in Tempo.

Adding deployment.environment to traces

It is very easy to add deployment.environment to traces as well.

webTracingScript.onload = () => {
        new window.GrafanaFaroWebTracing.TracingInstrumentation({
            resourceAttributes: {
                "deployment.environment": "production"

That is what I added to the Hugo Faro Analytics module:

git commmit

This is the result:

traces with deployment environment


Span metrics per environment

With this as a result, you can create dashboards where you can distinguish between the different environments. And if you use span metrics, it is possible to split the metrics of the environments with the dimensions configuration.

[ Update Januari 8th 21:30 CET ]
I created a pull request to make it part of the Faro Web SDK https://github.com/grafana/faro-web-sdk/pull/453

[ Update Januari 10th 11:45 CET ]
PR has been approved and merged and will be default from the next release onwards.

Originally published on Cees’ blog at https://ceesbos.nl/posts/20240108-grafana-faro-trace-with-deployment-environment/.

Cees Bos

Observability enthusiast, always looking for ways to improve software with better observability and what new insights can be gained. Delivering reliable software is always my priority. Combining existing tools often results in new ways to get an even better view. I work for OpenValue as a software engineer and SRE.