Getting started with OpenTelemetry

OpenTelemetry

Java Instrumentation with OpenTelemetry

    #!/bin/bash

    if [ $# -ne 3 ]; then
        echo "Usage: ./setup.sh [servicename] [endpoint] [logginglevel]"
        echo Example : ./setup.sh http://collector debug
        exit 1
    fi
        
    export OTEL_SERVICE_NAME=$1
    export OTEL_LOG_LEVEL=$3
    export OTEL_METRICS_EXPORTER=otlp
    export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
    export OTEL_EXPORTER_OTLP_ENDPOINT=$2:4318
    export OTEL_INSTRUMENTATION_OSHI_EXPERIMENTAL_METRICS_ENABLED=true
    export OTEL_INSTRUMENTATION_RUNTIME_TELEMETRY_EMIT_EXPERIMENTAL_TELEMETRY=true
    export OTEL_INSTRUMENTATION_HTTP_CLIENT_CAPTURE_REQUEST_HEADERS=Authorization,Cookie
    export OTEL_INSTRUMENTATION_HTTP_SERVER_CAPTURE_REQUEST_HEADERS=Authorization,Cookie
Usage : 
`./setup.sh [servicename] [endpoint] [logginglevel]`

+ __[servicename]__: service name.
+ __[endpoint]__ : url of Nudge Exporter (OTEL Collector).
+ __[logginglevel]__ : log level. Possible values : error, warn, info, debug, trace. Default value : info.

OSHI Core [Optional]

OSHI Core allows you to retrieve the “memory” metrics displayed in the Service/System tab.

Version 5.3.1 and above supported.

In pom.xml, add the required dependencies:

<!-- opentelemetry-->
    <dependency>
    <groupId>io.opentelemetry.instrumentation</groupId>
    <artifactId>opentelemetry-oshi</artifactId>
    <version>0.16.1</version>
    <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.github.oshi</groupId>
        <artifactId>oshi-core</artifactId>
        <version>5.3.1</version>
    </dependency>

In the Java application entry point, add the recording of metric observers.

import io.opentelemetry.instrumentation.oshi.ProcessMetrics;
import io.opentelemetry.instrumentation.oshi.SystemMetrics;
public static void main(String[] args) {
		/*
         * ...
         */
		SystemMetrics.registerObservers();
		ProcessMetrics.registerObservers();
	}

Launch of the application

java -javaagent:path/to/opentelemetry-javaagent.jar -jar myapp.jar

NodeJS Instrumentation with OpenTelemetry

Dotnet Instrumentation with OpenTelemetry

OpenTelemetry .NET automatic instrumentation should work with all officially supported operating systems and versions of .NET. The minimum supported version of .NET Framework is 4.6.2. The following processor architectures are supported: x86 AMD64 (x86-64) ARM64 (experimental)

We will be using OpenTelemetry v1.14.0.

Configuration

Add new applications to instrument

To add a new application to instrument, use the following command: WARNING! This command will restart IIS. Register-OpenTelemetryForIIS -OTelServiceName <service_name> -AppPoolName <app_pool_name> -OtelExporterOtlpEndpoint <endpoint_url><service_name> corresponds to the service name, <app_pool_name> is the name of the app pool in IIS, <endpoint_url> is the collector’s url (http://localhost:4318).

Add the following configuration block :

  attributes/<application_name>:
    actions:
      - action: insert
        key: nudge_application_id
        value: <app_id>
    include:
      match_type: strict
      resources:
        - key: service.name
          value: <service_name>
        - key: telemetry.sdk.language
          value: dotnet

  transform/<application_name>:
    error_mode: ignore
    metric_statements:
      - context: datapoint
        statements:
          - set(attributes["nudge_application_id"], "<app_id>")
            where resource.attributes["service.name"] == "<service_name>" and resource.attributes["telemetry.sdk.language"] == "dotnet"

Replace :

In the pipelines section, add :

service:
  pipelines:
    # Logs pipeline
    # Le pipeline logs (exceptions, errors ...) permet de traiter les logs envoyés par les applications.
    logs:
      receivers: [otlpnudge] #, uls]
      processors: [memory_limiter, insert_schema, attributes/<application_name>, logs_traces_merge, schema, batch]
      exporters: [nudgehttp] #, nudgedebug]

    # Traces pipeline
    # Le pipeline traces permet de traiter les traces HTTP, SQL, CQL ... envoyées par les applications.
    traces:
      receivers: [otlpnudge]
      processors: [memory_limiter, insert_schema, attributes/<application_name>, logs_traces_merge, schema, batch]
      exporters: [nudgehttp] #, nudgedebug]

    # Metrics pipeline
    # Le pipeline metrics permet de traiter les métriques disques, cpus, memoire ... envoyées par les applications.
    metrics:
      receivers: [otlpnudge]
      processors: [memory_limiter, insert_schema, transform/<application_name>, attributes/<application_name>, schema, batch]
      exporters: [nudgehttp] #, nudgedebug]

Sharepoint

Troubleshooting

Uninstall OpenTelemetry