Merge pull request #4797 from SigNoz/docker-instructions

Docker instructions
This commit is contained in:
CheetoDa 2024-04-04 13:13:48 +05:30 committed by GitHub
commit fd84d7b492
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
111 changed files with 4523 additions and 16 deletions

View File

@ -0,0 +1,106 @@
### Step 1: Install OpenTelemetry Dependencies
Dependencies related to OpenTelemetry exporter and SDK have to be installed first.
Run the below commands after navigating to the application source folder:
```bash
dotnet add package OpenTelemetry
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol
dotnet add package OpenTelemetry.Extensions.Hosting
dotnet add package OpenTelemetry.Instrumentation.Runtime
dotnet add package OpenTelemetry.Instrumentation.AspNetCore
dotnet add package OpenTelemetry.AutoInstrumentation
```
 
### Step 2: Adding OpenTelemetry as a service and configuring exporter options
In your `Program.cs` file, add OpenTelemetry as a service. Here, we are configuring these variables:
`serviceName` - It is the name of your service.
`otlpOptions.Endpoint` - It is the endpoint for your OTel Collector agent.
 
Heres a sample `Program.cs` file with the configured variables:
```bash
using System.Diagnostics;
using OpenTelemetry.Exporter;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
var builder = WebApplication.CreateBuilder(args);
// Configure OpenTelemetry with tracing and auto-start.
builder.Services.AddOpenTelemetry()
.ConfigureResource(resource =>
resource.AddService(serviceName: "{{MYAPP}}"))
.WithTracing(tracing => tracing
.AddAspNetCoreInstrumentation()
.AddOtlpExporter(otlpOptions =>
{
//sigNoz Cloud Endpoint
otlpOptions.Endpoint = new Uri("https://ingest.{{REGION}}.signoz.cloud:443");
otlpOptions.Protocol = OtlpExportProtocol.Grpc;
//SigNoz Cloud account Ingestion key
string headerKey = "signoz-access-token";
string headerValue = "{{SIGNOZ_INGESTION_KEY}}";
string formattedHeader = $"{headerKey}={headerValue}";
otlpOptions.Headers = formattedHeader;
}));
var app = builder.Build();
//The index route ("/") is set up to write out the OpenTelemetry trace information on the response:
app.MapGet("/", () => $"Hello World! OpenTelemetry Trace: {Activity.Current?.Id}");
app.Run();
```
 
The OpenTelemetry.Exporter.Options get or set the target to which the exporter is going to send traces. Here, were configuring it to send traces to the OTel Collector agent. The target must be a valid Uri with the scheme (http or https) and host and may contain a port and a path.
This is done by configuring an OpenTelemetry [TracerProvider](https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/docs/trace/customizing-the-sdk#readme) using extension methods and setting it to auto-start when the host is started.
### Step 3: Dockerize your application
Since the environment variables like SIGNOZ_INGESTION_KEY, Ingestion Endpoint and Service name are set in the `program.cs` file, you don't need to add any additional steps in your Dockerfile.
An **example** of a Dockerfile could look like this:
```bash
# Use the Microsoft official .NET SDK image to build the application
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /app
# Copy the CSPROJ file and restore any dependencies (via NUGET)
COPY *.csproj ./
RUN dotnet restore
# Copy the rest of the project files and build the application
COPY . ./
RUN dotnet publish -c Release -o out
# Generate the runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build-env /app/out .
# Expose port 5145 for the application
EXPOSE 5145
# Set the ASPNETCORE_URLS environment variable to listen on port 5145
ENV ASPNETCORE_URLS=http://+:5145
ENTRYPOINT ["dotnet", "YOUR-APPLICATION.dll"]
```

View File

@ -0,0 +1,21 @@
Once you update your Dockerfile, you can build and run it using the commands below.
 
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,101 @@
After setting up the Otel collector agent, follow the steps below to instrument your .NET Application
&nbsp;
&nbsp;
### Step 1: Install OpenTelemetry Dependencies
Install the following dependencies in your application.
```bash
dotnet add package OpenTelemetry
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol
dotnet add package OpenTelemetry.Extensions.Hosting
dotnet add package OpenTelemetry.Instrumentation.Runtime
dotnet add package OpenTelemetry.Instrumentation.AspNetCore
dotnet add package OpenTelemetry.AutoInstrumentation
```
&nbsp;
### Step 2: Adding OpenTelemetry as a service and configuring exporter options
In your `Program.cs` file, add OpenTelemetry as a service. Here, we are configuring these variables:
`serviceName` - It is the name of your service.
`otlpOptions.Endpoint` - It is the endpoint for your OTel Collector agent.
&nbsp;
Heres a sample `Program.cs` file with the configured variables:
```bash
using System.Diagnostics;
using OpenTelemetry.Exporter;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
var builder = WebApplication.CreateBuilder(args);
// Configure OpenTelemetry with tracing and auto-start.
builder.Services.AddOpenTelemetry()
.ConfigureResource(resource =>
resource.AddService(serviceName: "{{MYAPP}}"))
.WithTracing(tracing => tracing
.AddAspNetCoreInstrumentation()
.AddOtlpExporter(otlpOptions =>
{
otlpOptions.Endpoint = new Uri("http://localhost:4317");
otlpOptions.Protocol = OtlpExportProtocol.Grpc;
}));
var app = builder.Build();
//The index route ("/") is set up to write out the OpenTelemetry trace information on the response:
app.MapGet("/", () => $"Hello World! OpenTelemetry Trace: {Activity.Current?.Id}");
app.Run();
```
&nbsp;
The OpenTelemetry.Exporter.Options get or set the target to which the exporter is going to send traces. Here, were configuring it to send traces to the OTel Collector agent. The target must be a valid Uri with the scheme (http or https) and host and may contain a port and a path.
This is done by configuring an OpenTelemetry [TracerProvider](https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/docs/trace/customizing-the-sdk#readme) using extension methods and setting it to auto-start when the host is started.
&nbsp;
### Step 3: Dockerize your application
Since the crucial environment variables like SIGNOZ_INGESTION_KEY, Ingestion Endpoint and Service name are set in the `program.cs` file, you don't need to add any additional steps in your Dockerfile.
An **example** of a Dockerfile could look like this:
```bash
# Use the Microsoft official .NET SDK image to build the application
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /app
# Copy the CSPROJ file and restore any dependencies (via NUGET)
COPY *.csproj ./
RUN dotnet restore
# Copy the rest of the project files and build the application
COPY . ./
RUN dotnet publish -c Release -o out
# Generate the runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build-env /app/out .
# Expose port 5145 for the application
EXPOSE 5145
# Set the ASPNETCORE_URLS environment variable to listen on port 5145
ENV ASPNETCORE_URLS=http://+:5145
ENTRYPOINT ["dotnet", "YOUR-APPLICATION.dll"]
```

View File

@ -0,0 +1,21 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```

View File

@ -0,0 +1,67 @@
&nbsp;
Follow the steps below to instrument your Elixir (Phoenix + Ecto) Application
### Step 1: Add dependencies
Install dependencies related to OpenTelemetry by adding them to `mix.exs` file
```bash
{:opentelemetry_exporter, "~> 1.6"},
{:opentelemetry_api, "~> 1.2"},
{:opentelemetry, "~> 1.3"},
{:opentelemetry_semantic_conventions, "~> 0.2"},
{:opentelemetry_cowboy, "~> 0.2.1"},
{:opentelemetry_phoenix, "~> 1.1"},
{:opentelemetry_ecto, "~> 1.1"}
```
&nbsp;
In your application start, usually the `application.ex` file, setup the telemetry handlers
```bash
:opentelemetry_cowboy.setup()
OpentelemetryPhoenix.setup(adapter: :cowboy2)
OpentelemetryEcto.setup([:{{MYAPP}}, :repo])
```
&nbsp;
As an example, this is how you can setup the handlers in your application.ex file for an application called demo :
```bash
# application.ex
@impl true
def start(_type, _args) do
:opentelemetry_cowboy.setup()
OpentelemetryPhoenix.setup(adapter: :cowboy2)
OpentelemetryEcto.setup([:demo, :repo])
end
```
&nbsp;
### Step 2: Configure Application
You need to configure your application to send telemetry data by adding the following config to your `runtime.exs` file:
```bash
config :opentelemetry, :resource, service: %{name: "{{MYAPP}}"}
config :opentelemetry, :processors,
otel_batch_processor: %{
exporter: {
:opentelemetry_exporter,
%{
endpoints: ["https://ingest.{{REGION}}.signoz.cloud:443"],
headers: [
{"signoz-access-token", {{SIGNOZ_ACCESS_TOKEN}} }
]
}
}
}
```
&nbsp;
### Step 3: Dockerize your application
Since the environment variables like SIGNOZ_INGESTION_KEY, Ingestion Endpoint and Service name are set in the above steps, you don't need to add any additional steps in your Dockerfile.

View File

@ -0,0 +1,25 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
To see some examples for instrumented applications, you can checkout [this link](https://signoz.io/docs/instrumentation/elixir/#sample-examples)

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,61 @@
&nbsp;
After setting up the Otel collector agent, follow the steps below to instrument your Elixir (Phoenix + Ecto) Application
### Step 1: Add dependencies
Install dependencies related to OpenTelemetry by adding them to `mix.exs` file
```bash
{:opentelemetry_exporter, "~> 1.6"},
{:opentelemetry_api, "~> 1.2"},
{:opentelemetry, "~> 1.3"},
{:opentelemetry_semantic_conventions, "~> 0.2"},
{:opentelemetry_cowboy, "~> 0.2.1"},
{:opentelemetry_phoenix, "~> 1.1"},
{:opentelemetry_ecto, "~> 1.1"}
```
&nbsp;
In your application start, usually the `application.ex` file, setup the telemetry handlers
```bash
:opentelemetry_cowboy.setup()
OpentelemetryPhoenix.setup(adapter: :cowboy2)
OpentelemetryEcto.setup([:{{MYAPP}}, :repo])
```
&nbsp;
As an example, this is how you can setup the handlers in your application.ex file for an application called demo :
```bash
# application.ex
@impl true
def start(_type, _args) do
:opentelemetry_cowboy.setup()
OpentelemetryPhoenix.setup(adapter: :cowboy2)
OpentelemetryEcto.setup([:demo, :repo])
end
```
&nbsp;
### Step 2: Configure Application
You need to configure your application to send telemetry data by adding the following config to your `runtime.exs` file:
```bash
config :opentelemetry, :resource, service: %{name: "{{MYAPP}}"}
config :opentelemetry, :processors,
otel_batch_processor: %{
exporter:
{:opentelemetry_exporter,
%{endpoints: ["http://localhost:4318"]}
}
}
```
&nbsp;
### Step 3: Dockerize your application
Since the environment variables like SIGNOZ_INGESTION_KEY, Ingestion Endpoint and Service name are set in the above steps, you don't need to add any additional steps in your Dockerfile.

View File

@ -0,0 +1,25 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
To see some examples for instrumented applications, you can checkout [this link](https://signoz.io/docs/instrumentation/elixir/#sample-examples)

View File

@ -0,0 +1,135 @@
### Step 1: Install OpenTelemetry Dependencies
Dependencies related to OpenTelemetry exporter and SDK have to be installed first.
Run the below commands after navigating to the application source folder:
```bash
go get go.opentelemetry.io/otel \
go.opentelemetry.io/otel/trace \
go.opentelemetry.io/otel/sdk \
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin \
go.opentelemetry.io/otel/exporters/otlp/otlptrace \
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
```
**Note:** We are assuming you are using gin request router. If you are using other request routers, check out the [corresponding package](https://signoz.io/docs/instrumentation/golang/#request-routers).
&nbsp;
&nbsp;
### Step 2: Declare environment variables for configuring OpenTelemetry
Declare the following global variables in **`main.go`** which we will use to configure OpenTelemetry:
```bash
var (
serviceName = os.Getenv("SERVICE_NAME")
collectorURL = os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT")
insecure = os.Getenv("INSECURE_MODE")
)
```
&nbsp;
### Step 3: Instrument your Go application
To configure your application to send data we will need a function to initialize OpenTelemetry. Add the following snippet of code in your **`main.go`** file.
```bash
import (
.....
"google.golang.org/grpc/credentials"
"github.com/gin-gonic/gin"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)
func initTracer() func(context.Context) error {
var secureOption otlptracegrpc.Option
if strings.ToLower(insecure) == "false" || insecure == "0" || strings.ToLower(insecure) == "f" {
secureOption = otlptracegrpc.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, ""))
} else {
secureOption = otlptracegrpc.WithInsecure()
}
exporter, err := otlptrace.New(
context.Background(),
otlptracegrpc.NewClient(
secureOption,
otlptracegrpc.WithEndpoint(collectorURL),
),
)
if err != nil {
log.Fatalf("Failed to create exporter: %v", err)
}
resources, err := resource.New(
context.Background(),
resource.WithAttributes(
attribute.String("service.name", serviceName),
attribute.String("library.language", "go"),
),
)
if err != nil {
log.Fatalf("Could not set resources: %v", err)
}
otel.SetTracerProvider(
sdktrace.NewTracerProvider(
sdktrace.WithSampler(sdktrace.AlwaysSample()),
sdktrace.WithBatcher(exporter),
sdktrace.WithResource(resources),
),
)
return exporter.Shutdown
}
```
&nbsp;
### Step 4: Initialise the tracer in **`main.go`**
Modify the main function to initialise the tracer in **`main.go`**. Initiate the tracer at the very beginning of our main function.
```bash
func main() {
cleanup := initTracer()
defer cleanup(context.Background())
......
}
```
&nbsp;
### Step 5: Add the OpenTelemetry Gin middleware
Configure Gin to use the middleware by adding the following lines in **`main.go`**
```bash
import (
....
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
)
func main() {
......
r := gin.Default()
r.Use(otelgin.Middleware(serviceName))
......
}
```
&nbsp;
### Step 6: Dockerize your application
Set the environment variables in your Dockerfile.
```bash
...
# Set environment variables
ENV SERVICE_NAME={{MYAPP}} \
INSECURE_MODE=false \
OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=b{{SIGNOZ_INGESTION_KEY}}" \
OTEL_EXPORTER_OTLP_ENDPOINT=ingest.{{REGION}}.signoz.cloud:443
...
```

View File

@ -0,0 +1,21 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,137 @@
After setting up the Otel collector agent, follow the steps below to instrument your Go Application
&nbsp;
&nbsp;
### Step 1: Install OpenTelemetry Dependencies
Dependencies related to OpenTelemetry exporter and SDK have to be installed first.
Run the below commands after navigating to the application source folder:
```bash
go get go.opentelemetry.io/otel \
go.opentelemetry.io/otel/trace \
go.opentelemetry.io/otel/sdk \
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin \
go.opentelemetry.io/otel/exporters/otlp/otlptrace \
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
```
**Note:** We are assuming you are using gin request router. If you are using other request routers, check out the [corresponding package](https://signoz.io/docs/instrumentation/golang/#request-routers).
&nbsp;
&nbsp;
### Step 2: Declare environment variables for configuring OpenTelemetry
Declare the following global variables in **`main.go`** which we will use to configure OpenTelemetry:
```bash
var (
serviceName = os.Getenv("SERVICE_NAME")
collectorURL = os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT")
insecure = os.Getenv("INSECURE_MODE")
)
```
&nbsp;
### Step 3: Instrument your Go application
To configure your application to send data we will need a function to initialize OpenTelemetry. Add the following snippet of code in your **`main.go`** file.
```bash
import (
.....
"google.golang.org/grpc/credentials"
"github.com/gin-gonic/gin"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)
func initTracer() func(context.Context) error {
var secureOption otlptracegrpc.Option
if strings.ToLower(insecure) == "false" || insecure == "0" || strings.ToLower(insecure) == "f" {
secureOption = otlptracegrpc.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, ""))
} else {
secureOption = otlptracegrpc.WithInsecure()
}
exporter, err := otlptrace.New(
context.Background(),
otlptracegrpc.NewClient(
secureOption,
otlptracegrpc.WithEndpoint(collectorURL),
),
)
if err != nil {
log.Fatalf("Failed to create exporter: %v", err)
}
resources, err := resource.New(
context.Background(),
resource.WithAttributes(
attribute.String("service.name", serviceName),
attribute.String("library.language", "go"),
),
)
if err != nil {
log.Fatalf("Could not set resources: %v", err)
}
otel.SetTracerProvider(
sdktrace.NewTracerProvider(
sdktrace.WithSampler(sdktrace.AlwaysSample()),
sdktrace.WithBatcher(exporter),
sdktrace.WithResource(resources),
),
)
return exporter.Shutdown
}
```
&nbsp;
### Step 4: Initialise the tracer in **`main.go`**
Modify the main function to initialise the tracer in **`main.go`**. Initiate the tracer at the very beginning of our main function.
```bash
func main() {
cleanup := initTracer()
defer cleanup(context.Background())
......
}
```
&nbsp;
### Step 5: Add the OpenTelemetry Gin middleware
Configure Gin to use the middleware by adding the following lines in **`main.go`**
```bash
import (
....
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
)
func main() {
......
r := gin.Default()
r.Use(otelgin.Middleware(serviceName))
......
}
```
&nbsp;
### Step 6: Dockerize your application
Set the environment variables in your Dockerfile.
```bash
...
# Set environment variables
ENV SERVICE_NAME={{MYAPP}} \
INSECURE_MODE=true \
OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317
...
```

View File

@ -0,0 +1,21 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```

View File

@ -1,7 +1,3 @@
After setting up the Otel collector agent, follow the steps below to instrument your Go Application
&nbsp;
&nbsp;
### Step 1: Install OpenTelemetry Dependencies
Dependencies related to OpenTelemetry exporter and SDK have to be installed first.

View File

@ -1,7 +1,3 @@
After setting up the Otel collector agent, follow the steps below to instrument your Go Application
&nbsp;
&nbsp;
### Step 1: Install OpenTelemetry Dependencies
Dependencies related to OpenTelemetry exporter and SDK have to be installed first.

View File

@ -1,7 +1,3 @@
After setting up the Otel collector agent, follow the steps below to instrument your Go Application
&nbsp;
&nbsp;
### Step 1: Install OpenTelemetry Dependencies
Dependencies related to OpenTelemetry exporter and SDK have to be installed first.

View File

@ -1,7 +1,3 @@
After setting up the Otel collector agent, follow the steps below to instrument your Go Application
&nbsp;
&nbsp;
### Step 1: Install OpenTelemetry Dependencies
Dependencies related to OpenTelemetry exporter and SDK have to be installed first.

View File

@ -0,0 +1,25 @@
#### Requirements
- Java 8 or higher
&nbsp;
### Dockerize your application
Update your Dockerfile to include
```bash
...
# Set working directory. Assuming `/opt/jboss-eap-7.1` to be your working directory.
WORKDIR /opt/jboss-eap-7.1
# Download otel java binary agent
RUN wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar -O opentelemetry-javaagent.jar
# Open and update the configuration file
RUN sed -i 's/\(JAVA_OPTS=".*\)/\1 -javaagent:\/opt\/jboss-eap-7.1\/opentelemetry-javaagent.jar \
-Dotel.exporter.otlp.endpoint=https:\/\/ingest.{{REGION}}.signoz.cloud:443 \
-Dotel.exporter.otlp.headers="signoz-access-token={{SIGNOZ_INGESTION_KEY}}" \
-Dotel.resource.attributes="service.name={{MYAPP}}"/' /opt/jboss-eap-7.1/bin/standalone.conf
...
```

View File

@ -0,0 +1,25 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/jboss/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,24 @@
After setting up the Otel collector agent, follow the steps below to instrument your JavaScript Application
#### Requirements
- Java 8 or higher
&nbsp;
### Dockerize your application
Update your Dockerfile to include
```bash
...
# Set working directory. Assuming `/opt/jboss-eap-7.1` to be your working directory.
WORKDIR /opt/jboss-eap-7.1
# Download otel java binary agent
RUN wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar -O opentelemetry-javaagent.jar
# Open and update the configuration file
RUN sed -i 's/\(JAVA_OPTS=".*\)/\1 -javaagent:\/opt\/jboss-eap-7.1\/opentelemetry-javaagent.jar/' bin/standalone.conf
...
```

View File

@ -0,0 +1,25 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/jboss/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,27 @@
#### Requirements
- Java 8 or higher
&nbsp;
### Dockerize your application
Add the following to your Dockerfile
```bash
...
# Download otel java binary agent using
RUN wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar -O opentelemetry-javaagent.jar
# Set environment variables and run your Spring Boot application
ENV OTEL_RESOURCE_ATTRIBUTES="service.name={{MYAPP}}" \
OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token={{SIGNOZ_INGESTION_KEY}}" \
OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.{{REGION}}.signoz.cloud:443"
# Copy the Spring Boot application JAR file into the container
COPY <my-app>.jar /app
# Command to run the Spring Boot application
CMD ["java", "-javaagent:/app/opentelemetry-javaagent.jar", "-jar", "/app/<my-app>.jar"]
...
```

View File

@ -0,0 +1,27 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/java/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,22 @@
After setting up the Otel collector agent, follow the steps below to instrument your Java Application
#### Requirements
- Java 8 or higher
&nbsp;
### Dockerize your application
Add the following to your Dockerfile
```bash
...
# Download otel java binary agent using
RUN wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar -O opentelemetry-javaagent.jar
# Copy the Spring Boot application JAR file into the container
COPY <my-app>.jar /app
# Command to run the Spring Boot application
CMD ["java", "-javaagent:/app/opentelemetry-javaagent.jar", "-jar", "/app/<my-app>.jar"]
...
```

View File

@ -0,0 +1,26 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/java/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,27 @@
#### Requirements
- Java 8 or higher
&nbsp;
### Dockerize your application
Add the following to your Dockerfile
```bash
...
# Download otel java binary agent using
RUN wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar -O opentelemetry-javaagent.jar
# Set environment variables and run your Spring Boot application
ENV OTEL_RESOURCE_ATTRIBUTES="service.name={{MYAPP}}" \
OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token={{SIGNOZ_INGESTION_KEY}}" \
OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.{{REGION}}.signoz.cloud:443"
# Copy the Spring Boot application JAR file into the container
COPY <my-app>.jar /app
# Command to run the Spring Boot application
CMD ["java", "-javaagent:/app/opentelemetry-javaagent.jar", "-jar", "/app/<my-app>.jar"]
...
```

View File

@ -0,0 +1,28 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/springboot/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,22 @@
After setting up the Otel collector agent, follow the steps below to instrument your Java Application
#### Requirements
- Java 8 or higher
&nbsp;
### Dockerize your application
Add the following to your Dockerfile
```bash
...
# Download otel java binary agent using
RUN wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar -O opentelemetry-javaagent.jar
# Copy the Spring Boot application JAR file into the container
COPY <my-app>.jar /app
# Command to run the Spring Boot application
CMD ["java", "-javaagent:/app/opentelemetry-javaagent.jar", "-jar", "/app/<my-app>.jar"]
...
```

View File

@ -0,0 +1,26 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/springboot/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,33 @@
#### Requirements
- Java 8 or higher
&nbsp;
### Create setenv.sh file
Create a `setenv.sh` file in the same directory as your Dockerfile
```bash
#!/bin/sh
export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/usr/local/tomcat/opentelemetry-javaagent.jar"
export OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token={{SIGNOZ_INGESTION_KEY}}"
export OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.{{REGION}}.signoz.cloud:443
export OTEL_RESOURCE_ATTRIBUTES=service.name={{MYAPP}}
```
&nbsp;
### Dockerize your application
Update your Dockerfile with the below commands
```bash
...
# Set working directory. Here /usr/local/tomcat is assumed to be the working directory
WORKDIR /usr/local/tomcat
# Download otel java binary agent
RUN wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar -O opentelemetry-javaagent.jar
# Copy setenv.sh into Tomcat bin directory of the working directory to enable the instrumentation agent
COPY setenv.sh /usr/local/tomcat/bin/
...
```

View File

@ -0,0 +1,26 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/tomcat/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,96 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
### Step 1: Download otel-collector tar.gz
```bash
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.79.0/otelcol-contrib_0.79.0_linux_amd64.tar.gz
```
&nbsp;
### Step 2: Extract otel-collector tar.gz to the `otelcol-contrib` folder
```bash
mkdir otelcol-contrib && tar xvzf otelcol-contrib_0.79.0_linux_amd64.tar.gz -C otelcol-contrib
```
&nbsp;
### Step 3: Create config.yaml in folder otelcol-contrib with the below content in it
```bash
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
hostmetrics:
collection_interval: 60s
scrapers:
cpu: {}
disk: {}
load: {}
filesystem: {}
memory: {}
network: {}
paging: {}
process:
mute_process_name_error: true
mute_process_exe_error: true
mute_process_io_error: true
processes: {}
prometheus:
config:
global:
scrape_interval: 60s
scrape_configs:
- job_name: otel-collector-binary
static_configs:
- targets:
# - localhost:8888
processors:
batch:
send_batch_size: 1000
timeout: 10s
# Ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/resourcedetectionprocessor/README.md
resourcedetection:
detectors: [env, system] # Before system detector, include ec2 for AWS, gcp for GCP and azure for Azure.
# Using OTEL_RESOURCE_ATTRIBUTES envvar, env detector adds custom labels.
timeout: 2s
system:
hostname_sources: [os] # alternatively, use [dns,os] for setting FQDN as host.name and os as fallback
extensions:
health_check: {}
zpages: {}
exporters:
otlp:
endpoint: "ingest.{{REGION}}.signoz.cloud:443"
tls:
insecure: false
headers:
"signoz-access-token": "{{SIGNOZ_INGESTION_KEY}}"
logging:
verbosity: normal
service:
telemetry:
metrics:
address: 0.0.0.0:8888
extensions: [health_check, zpages]
pipelines:
metrics:
receivers: [otlp]
processors: [batch]
exporters: [otlp]
metrics/internal:
receivers: [prometheus, hostmetrics]
processors: [resourcedetection, batch]
exporters: [otlp]
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlp]
logs:
receivers: [otlp]
processors: [batch]
exporters: [otlp]
```

View File

@ -0,0 +1,30 @@
After setting up the Otel collector agent, follow the steps below to instrument your Java Application
#### Requirements
- Java 8 or higher
&nbsp;
Create a `setenv.sh` file in the same directory as your Dockerfile
```bash
#!/bin/sh
export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/usr/local/tomcat/opentelemetry-javaagent.jar"
```
&nbsp;
### Dockerize your application
Update your Dockerfile with the below commands
```bash
...
# Set working directory. Here /usr/local/tomcat is assumed to be the working directory
WORKDIR /usr/local/tomcat
# Download otel java binary agent
RUN wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar -O opentelemetry-javaagent.jar
# Copy setenv.sh into Tomcat bin directory of the working directory to enable the instrumentation agent
COPY setenv.sh /usr/local/tomcat/bin/
...
```

View File

@ -0,0 +1,26 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/tomcat/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,71 @@
#### Requirements
- Supported Versions ^4.0.0
&nbsp;
### Step 1: Install OpenTelemetry packages
```bash
npm install --save @opentelemetry/api@^1.6.0
npm install --save @opentelemetry/sdk-node@^0.45.0
npm install --save @opentelemetry/auto-instrumentations-node@^0.39.4
npm install --save @opentelemetry/exporter-trace-otlp-http@^0.45.0
```
&nbsp;
### Step 2: Create tracing.js file
```bash
// tracing.js
'use strict'
const process = require('process');
const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
// do not set headers in exporterOptions, the OTel spec recommends setting headers through ENV variables
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#specifying-headers-via-environment-variables
const exporterOptions = {
url: 'https://ingest.{{REGION}}.signoz.cloud:443/v1/traces'
}
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}'
})
});
// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start()
// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
sdk.shutdown()
.then(() => console.log('Tracing terminated'))
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});
```
&nbsp;
### Step 3: Dockerize your application
Set the SigNoz ingestion key Environment variable and update your run command to include the `-r` flag and `./tracing.js` file in Dockerfile as:
```bash
...
# Use an environment variable for the Signoz Ingestion Key
ENV OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token={{SIGNOZ_INGESTION_KEY}}"
# Run the app with the required OpenTelemetry configuration. app.js is your application main file.
CMD ["node", "-r", "./tracing.js", "app.js"]
...
```

View File

@ -0,0 +1,28 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/express/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,66 @@
After setting up the Otel collector agent, follow the steps below to instrument your JavaScript Application
#### Requirements
- Supported Versions ^4.0.0
&nbsp;
### Step 1: Install OpenTelemetry packages
```bash
npm install --save @opentelemetry/api@^1.6.0
npm install --save @opentelemetry/sdk-node@^0.45.0
npm install --save @opentelemetry/auto-instrumentations-node@^0.39.4
npm install --save @opentelemetry/exporter-trace-otlp-http@^0.45.0
```
&nbsp;
### Step 2: Create tracing.js file
```bash
// tracing.js
'use strict'
const process = require('process');
const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const exporterOptions = {
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces',
}
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}'
})
});
// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start()
// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
sdk.shutdown()
.then(() => console.log('Tracing terminated'))
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});
```
&nbsp;
### Step 3: Dockerize your application
Set the SigNoz ingestion key Environment variable and update your run command to include the `-r` flag and `./tracing.js` file in Dockerfile as:
```bash
...
# Run the app with the required OpenTelemetry configuration. app.js is your application main file.
CMD ["node", "-r", "./tracing.js", "app.js"]
...
```

View File

@ -0,0 +1,28 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/express/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,103 @@
#### Requirements
- Supported Versions >= `4.0.0`
&nbsp;
### Step 1: Install OpenTelemetry packages
```bash
npm install --save @opentelemetry/api@^1.6.0
npm install --save @opentelemetry/sdk-node@^0.45.0
npm install --save @opentelemetry/auto-instrumentations-node@^0.39.4
npm install --save @opentelemetry/exporter-trace-otlp-http@^0.45.0
```
&nbsp;
### Step 2: Create tracing.js file
```javascript
'use strict';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import * as opentelemetry from '@opentelemetry/sdk-node';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
// Configure the SDK to export telemetry data to the console
// Enable all auto-instrumentations from the meta package
const exporterOptions = {
url: 'https://ingest.{{REGION}}.signoz.cloud:443/v1/traces',
};
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}',
}),
});
// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start();
// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
sdk
.shutdown()
.then(() => console.log('Tracing terminated'))
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});
export default sdk;
```
&nbsp;
### Step 3: Import tracer in the `main.js file`
**Important Note**: The below import should be the first line in the main file of your application (Ex -> `main.ts`)
```bash
const tracer = require('./tracer')
```
&nbsp;
### Step 4: Start the tracer
In the `async function boostrap` section of the application code, initialize the tracer as follows:
```javascript
const tracer = require('./tracer')
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
// All of your application code and any imports that should leverage
// OpenTelemetry automatic instrumentation must go here.
async function bootstrap() {
await tracer.start();
const app = await NestFactory.create(AppModule);
await app.listen(3001);
}
bootstrap();
```
&nbsp;
### Step 5: Dockerize your application
Set the SigNoz ingestion key Environment variable and expose port 3001 in Dockerfile as:
```bash
...
# Use an environment variable for the Signoz Ingestion Key
ENV OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token={{SIGNOZ_INGESTION_KEY}}"
# In step 4 above, you are configuring your NestJS application to listen on port 3001
EXPOSE 3001
# Run the app with the required OpenTelemetry configuration.
CMD [ "nest", "start" ]
...
```

View File

@ -0,0 +1,28 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/nestjs/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,104 @@
&nbsp;
After setting up the Otel collector agent, follow the steps below to instrument your JavaScript Application
#### Requirements
- Supported Versions >= `4.0.0`
&nbsp;
### Step 1: Install OpenTelemetry packages
```bash
npm install --save @opentelemetry/api@^1.6.0
npm install --save @opentelemetry/sdk-node@^0.45.0
npm install --save @opentelemetry/auto-instrumentations-node@^0.39.4
npm install --save @opentelemetry/exporter-trace-otlp-http@^0.45.0
```
&nbsp;
### Step 2: Create tracing.js file
```bash
'use strict';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import * as opentelemetry from '@opentelemetry/sdk-node';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
// Configure the SDK to export telemetry data to the console
// Enable all auto-instrumentations from the meta package
const exporterOptions = {
url: 'http://localhost:4318/v1/traces',
};
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}',
}),
});
// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start();
// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
sdk
.shutdown()
.then(() => console.log('Tracing terminated'))
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});
export default sdk;
```
&nbsp;
### Step 3: Import tracer in the `main.js file`
**Important Note**: The below import should be the first line in the main file of your application (Ex -> `main.ts`)
```bash
const tracer = require('./tracer')
```
&nbsp;
### Step 4: Start the tracer
In the `async function boostrap` section of the application code, initialize the tracer as follows:
```bash
const tracer = require('./tracer')
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
// All of your application code and any imports that should leverage
// OpenTelemetry automatic instrumentation must go here.
async function bootstrap() {
await tracer.start();
const app = await NestFactory.create(AppModule);
await app.listen(3001);
}
bootstrap();
```
&nbsp;
### Step 5: Dockerize your application
Expose port 3001 in Dockerfile as:
```bash
...
# In step 4 above, you are configuring your NestJS application to listen on port 3001
EXPOSE 3001
# Run the app with the required OpenTelemetry configuration.
CMD [ "nest", "start" ]
...
```

View File

@ -0,0 +1,28 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/nestjs/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,70 @@
#### Requirements
- NodeJS Version 14 or newer
&nbsp;
### Step 1: Install OpenTelemetry packages
```bash
npm install --save @opentelemetry/api@^1.6.0
npm install --save @opentelemetry/sdk-node@^0.45.0
npm install --save @opentelemetry/auto-instrumentations-node@^0.39.4
npm install --save @opentelemetry/exporter-trace-otlp-http@^0.45.0
```
&nbsp;
### Step 2: Create tracing.js file
```bash
// tracing.js
'use strict'
const process = require('process');
const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
// do not set headers in exporterOptions, the OTel spec recommends setting headers through ENV variables
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#specifying-headers-via-environment-variables
const exporterOptions = {
url: 'https://ingest.{{REGION}}.signoz.cloud:443/v1/traces'
}
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}'
})
});
// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start()
// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
sdk.shutdown()
.then(() => console.log('Tracing terminated'))
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});
```
### Step 3: Dockerize your application
Set the SigNoz ingestion key Environment variable and update your run command to include the `-r` flag and `./tracing.js` file in Dockerfile as:
```bash
...
# Use an environment variable for the Signoz Ingestion Key
ENV OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token={{SIGNOZ_INGESTION_KEY}}"
# Run the app with the required OpenTelemetry configuration. app.js is your application main file.
CMD ["node", "-r", "./tracing.js", "app.js"]
...
```

View File

@ -0,0 +1,28 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/javascript/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,67 @@
&nbsp;
After setting up the Otel collector agent, follow the steps below to instrument your JavaScript Application
#### Requirements
- NodeJS Version 14 or newer
&nbsp;
### Step 1: Install OpenTelemetry packages
```bash
npm install --save @opentelemetry/api@^1.6.0
npm install --save @opentelemetry/sdk-node@^0.45.0
npm install --save @opentelemetry/auto-instrumentations-node@^0.39.4
npm install --save @opentelemetry/exporter-trace-otlp-http@^0.45.0
```
&nbsp;
### Step 2: Create tracing.js file
```bash
// tracing.js
'use strict'
const process = require('process');
const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const exporterOptions = {
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces',
}
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}'
})
});
// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start()
// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
sdk.shutdown()
.then(() => console.log('Tracing terminated'))
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});
```
### Step 3: Dockerize your application
Set the SigNoz ingestion key Environment variable and update your run command to include the `-r` flag and `./tracing.js` file in Dockerfile as:
```bash
...
# Run the app with the required OpenTelemetry configuration. app.js is your application main file.
CMD ["node", "-r", "./tracing.js", "app.js"]
...
```

View File

@ -0,0 +1,28 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/javascript/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,70 @@
#### Requirements
- NodeJS Version 14 or newer
&nbsp;
### Step 1: Install OpenTelemetry packages
```bash
npm install --save @opentelemetry/api@^1.6.0
npm install --save @opentelemetry/sdk-node@^0.45.0
npm install --save @opentelemetry/auto-instrumentations-node@^0.39.4
npm install --save @opentelemetry/exporter-trace-otlp-http@^0.45.0
```
&nbsp;
### Step 2: Create tracing.js file
```bash
// tracing.js
'use strict'
const process = require('process');
const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
// do not set headers in exporterOptions, the OTel spec recommends setting headers through ENV variables
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#specifying-headers-via-environment-variables
const exporterOptions = {
url: 'https://ingest.{{REGION}}.signoz.cloud:443/v1/traces'
}
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}'
})
});
// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start()
// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
sdk.shutdown()
.then(() => console.log('Tracing terminated'))
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});
```
### Step 3: Dockerize your application
Set the SigNoz ingestion key Environment variable and update your run command to include the `-r` flag and `./tracing.js` file in Dockerfile as:
```bash
...
# Use an environment variable for the Signoz Ingestion Key
ENV OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token={{SIGNOZ_INGESTION_KEY}}"
# Run the app with the required OpenTelemetry configuration. app.js is your application main file.
CMD ["node", "-r", "./tracing.js", "app.js"]
...
```

View File

@ -0,0 +1,28 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/javascript/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,67 @@
&nbsp;
After setting up the Otel collector agent, follow the steps below to instrument your JavaScript Application
#### Requirements
- NodeJS Version 14 or newer
&nbsp;
### Step 1: Install OpenTelemetry packages
```bash
npm install --save @opentelemetry/api@^1.6.0
npm install --save @opentelemetry/sdk-node@^0.45.0
npm install --save @opentelemetry/auto-instrumentations-node@^0.39.4
npm install --save @opentelemetry/exporter-trace-otlp-http@^0.45.0
```
&nbsp;
### Step 2: Create tracing.js file
```bash
// tracing.js
'use strict'
const process = require('process');
const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const exporterOptions = {
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces',
}
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}'
})
});
// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start()
// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
sdk.shutdown()
.then(() => console.log('Tracing terminated'))
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});
```
### Step 3: Dockerize your application
Set the SigNoz ingestion key Environment variable and update your run command to include the `-r` flag and `./tracing.js` file in Dockerfile as:
```bash
...
# Run the app with the required OpenTelemetry configuration. app.js is your application main file.
CMD ["node", "-r", "./tracing.js", "app.js"]
...
```

View File

@ -0,0 +1,28 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/javascript/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,85 @@
### Step 1: Install OpenTelemetry packages
```bash
npm install --save @opentelemetry/context-zone
npm install --save @opentelemetry/instrumentation
npm install --save @opentelemetry/auto-instrumentations-web
npm install --save @opentelemetry/sdk-trace-base
npm install --save @opentelemetry/sdk-trace-web
npm install --save @opentelemetry/resources
npm install --save @opentelemetry/semantic-conventions
npm install --save @opentelemetry/exporter-trace-otlp-http
```
&nbsp;
### Step 2: Create tracing.js file
```javascript
// tracing.js
import { ZoneContextManager } from '@opentelemetry/context-zone';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations-web';
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
import { Resource } from '@opentelemetry/resources';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
const provider = new WebTracerProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}',
}),
});
const exporter = new OTLPTraceExporter({
url: 'https://ingest.{{REGION}}.signoz.cloud:443/v1/traces',
headers: {
"signoz-access-token": "{{SIGNOZ_INGESTION_KEY}}",
},
});
provider.addSpanProcessor(new BatchSpanProcessor(exporter));
provider.register({
// Changing default contextManager to use ZoneContextManager - supports asynchronous operations so that traces are not broken
contextManager: new ZoneContextManager(),
});
// Registering instrumentations
registerInstrumentations({
instrumentations: [
getWebAutoInstrumentations({
'@opentelemetry/instrumentation-xml-http-request': {
propagateTraceHeaderCorsUrls: [
/.+/g, //Regex to match your backend urls.
],
},
'@opentelemetry/instrumentation-fetch': {
propagateTraceHeaderCorsUrls: [
/.+/g, //Regex to match your backend urls.
],
},
}),
],
});
```
### Step 3: Import tracer in main file
**Important Note**: The below import should be the first line in the main file of your application (Ex -> `index.js`)
```bash
import './tracing.js'
// ...rest of the app's entry point code
```
&nbsp;
### Step 4: Dockerize your application
```bash
...
# Run the app with the required OpenTelemetry configuration.
CMD [ "npm", "start" ]
...
```

View File

@ -0,0 +1,28 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult this [documentation](https://signoz.io/docs/instrumentation/reactjs/) for assistance.

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,79 @@
### Step 1: Install OpenTelemetry packages
```bash
npm install --save @opentelemetry/context-zone
npm install --save @opentelemetry/instrumentation
npm install --save @opentelemetry/auto-instrumentations-web
npm install --save @opentelemetry/sdk-trace-base
npm install --save @opentelemetry/sdk-trace-web
npm install --save @opentelemetry/resources
npm install --save @opentelemetry/semantic-conventions
npm install --save @opentelemetry/exporter-trace-otlp-http
```
&nbsp;
### Step 2: Create tracing.js file
```javascript
// tracing.js
import { ZoneContextManager } from '@opentelemetry/context-zone';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations-web';
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
import { Resource } from '@opentelemetry/resources';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
const provider = new WebTracerProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}',
}),
});
const exporter = new OTLPTraceExporter({
url: 'http://localhost:4318/v1/traces',
});
provider.addSpanProcessor(new BatchSpanProcessor(exporter));
provider.register({
// Changing default contextManager to use ZoneContextManager - supports asynchronous operations so that traces are not broken
contextManager: new ZoneContextManager(),
});
// Registering instrumentations
registerInstrumentations({
instrumentations: [
getWebAutoInstrumentations({
'@opentelemetry/instrumentation-xml-http-request': {
propagateTraceHeaderCorsUrls: [
/.+/g, //Regex to match your backend urls.
],
},
'@opentelemetry/instrumentation-fetch': {
propagateTraceHeaderCorsUrls: [
/.+/g, //Regex to match your backend urls.
],
},
}),
],
});
```
### Step 3: Import tracer in main file
**Important Note**: The below import should be the first line in the main file of your application (Ex -> `index.js`)
```bash
import './tracing.js'
// ...rest of the app's entry point code
```
### Step 4: Dockerize your application
```bash
...
# Run the app with the required OpenTelemetry configuration.
CMD [ "npm", "start" ]
...
```

View File

@ -0,0 +1,28 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult this [documentation](https://signoz.io/docs/instrumentation/reactjs/) for assistance.

View File

@ -0,0 +1,79 @@
&nbsp;
### Step 1: Setup Development Environment
Add these crates just below the `[dependencies]` section of your `cargo.toml` file
To configure our PHP application to send data, you need to use OpenTelemetry PHP extension. Since the extension is built from the source, you need to have the build tools, which can be installed using the following command:
**Linux**:
```bash
sudo apt-get install gcc make autoconf
```
**MacOs(Homebrew)**:
```bash
brew install gcc make autoconf
```
&nbsp;
### Step 2: Build the extension
With our environment set up we can install the extension using [PECL](https://pecl.php.net/):
```bash
pecl install opentelemetry
```
After successfully installing the OpenTelemetry extension, add the extension to php.ini file of your project:
```bash
[opentelemetry]
extension=opentelemetry.so
```
Verify that the extension is enabled by running:
```bash
php -m | grep opentelemetry
```
Running the above command will **output**:
```bash
opentelemetry
```
&nbsp;
### Step 3: Add the dependencies
Add dependencies required to perform automatic instrumentation using this command :
```bash
composer config allow-plugins.php-http/discovery false
composer require \
open-telemetry/sdk \
open-telemetry/exporter-otlp \
php-http/guzzle7-adapter \
open-telemetry/transport-grpc
```
&nbsp;
### Step 4: Dockerize your application
Update your dockerfile to include the environment variables:
```bash
...
# Set environment variables
ENV OTEL_PHP_AUTOLOAD_ENABLED=true \
OTEL_SERVICE_NAME={{MYAPP}} \
OTEL_TRACES_EXPORTER=otlp \
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.{{REGION}}.signoz.cloud:443 \
OTEL_EXPORTER_OTLP_HEADERS=signoz-access-token={{SIGNOZ_INGESTION_KEY}} \
OTEL_PROPAGATORS=baggage,tracecontext
...
```

View File

@ -0,0 +1,21 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,84 @@
&nbsp;
After setting up the Otel collector agent, follow the steps below to instrument your PHP Application
### Step 1: Setup Development Environment
Add these crates just below the `[dependencies]` section of your `cargo.toml` file
To configure our PHP application to send data, you need to use OpenTelemetry PHP extension. Since the extension is built from the source, you need to have the build tools, which can be installed using the following command:
**Linux**:
```bash
sudo apt-get install gcc make autoconf
```
&nbsp;
**MacOs(Homebrew)**:
```bash
brew install gcc make autoconf
```
&nbsp;
### Step 2: Build the extension
With our environment set up we can install the extension using [PECL](https://pecl.php.net/):
```bash
pecl install opentelemetry
```
After successfully installing the OpenTelemetry extension, add the extension to php.ini file of your project:
```bash
[opentelemetry]
extension=opentelemetry.so
```
Verify that the extension is enabled by running:
```bash
php -m | grep opentelemetry
```
Running the above command will **output**:
```bash
opentelemetry
```
&nbsp;
### Step 3: Add the dependencies
Add dependencies required to perform automatic instrumentation using this command :
```bash
composer config allow-plugins.php-http/discovery false
composer require \
open-telemetry/sdk \
open-telemetry/exporter-otlp \
php-http/guzzle7-adapter \
open-telemetry/transport-grpc
```
&nbsp;
### Step 4: Dockerize your application
Update your dockerfile to include the environment variables:
```bash
...
# Set environment variables
ENV OTEL_PHP_AUTOLOAD_ENABLED=true \
OTEL_SERVICE_NAME={{MYAPP}} \
OTEL_TRACES_EXPORTER=otlp \
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \
OTEL_EXPORTER_OTLP_ENDPOINT=<COLLECTOR-ENDPOINT> \
OTEL_PROPAGATORS=baggage,tracecontext
...
```
- <COLLECTOR_ENDPOINT> - Endpoint at which the collector is running. Ex. -> `http://localhost:4317`

View File

@ -0,0 +1,21 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```

View File

@ -0,0 +1,54 @@
#### Requirements
- Python 3.8 or newer
- for Django, you must define `DJANGO_SETTINGS_MODULE` correctly. If your project is called `mysite`, something like following should work:
```bash
export DJANGO_SETTINGS_MODULE=mysite.settings
```
&nbsp;
### Step 1 : Add OpenTelemetry dependencies
In your `requirements.txt` file, add these two OpenTelemetry dependencies:
```bash
opentelemetry-distro==0.43b0
opentelemetry-exporter-otlp==1.22.0
```
&nbsp;
### Step 2 : Dockerize your application
Update your dockerfile along with OpenTelemetry instructions as shown below:
```bash
...
# Install any needed packages specified in requirements.txt
# And install OpenTelemetry packages
RUN pip install --no-cache-dir -r requirements.txt
RUN opentelemetry-bootstrap --action=install
# (Optional) Make port 5000 available to the world outside this container (You can choose your own port for this)
EXPOSE 5000
# Set environment variables for OpenTelemetry
ENV OTEL_RESOURCE_ATTRIBUTES=service.name={{MYAPP}}
ENV OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.{REGION}.signoz.cloud:443
ENV OTEL_EXPORTER_OTLP_HEADERS=signoz-access-token={{SIGNOZ_INGESTION_KEY}}
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# Run app.py with OpenTelemetry instrumentation when the container launches
CMD ["opentelemetry-instrument", "<your_run_command>"]
...
```
- <your_run_command> can be `python3 app.py` or `python manage.py runserver --noreload`

View File

@ -0,0 +1,29 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
The Docker run command starts a container in detached mode (-d) and maps port 5000 of the host to port 5000 of the container.
```bash
docker run -d -p 5000:5000 <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/django/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,59 @@
&nbsp;
After setting up the Otel collector agent, follow the steps below to Dockerize your Python Application
#### Requirements
- Python 3.8 or newer
- for Django, you must define `DJANGO_SETTINGS_MODULE` correctly. If your project is called `mysite`, something like following should work:
```bash
export DJANGO_SETTINGS_MODULE=mysite.settings
```
&nbsp;
### Step 1 : Add OpenTelemetry dependencies
In your `requirements.txt` file, add these two OpenTelemetry dependencies:
```bash
opentelemetry-distro==0.43b0
opentelemetry-exporter-otlp==1.22.0
```
&nbsp;
### Step 2 : Dockerize your application
Update your Dockerfile along with OpenTelemetry instructions as shown below:
```bash
...
# Install any needed packages specified in requirements.txt
# And install OpenTelemetry packages
RUN pip install --no-cache-dir -r requirements.txt
RUN opentelemetry-bootstrap --action=install
# (Optional) Make port 5000 available to the world outside this container (You can choose your own port for this)
EXPOSE 5000
# Set environment variables for OpenTelemetry
ENV OTEL_RESOURCE_ATTRIBUTES=service.name={{MYAPP}}
ENV OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# Run app.py with OpenTelemetry instrumentation when the container launches
CMD ["opentelemetry-instrument", "<your_run_command>"]
...
```
- <your_run_command> can be `python3 app.py` or `python manage.py runserver --noreload`

View File

@ -0,0 +1,25 @@
Once you update your Dockerfile, you can build and run it using the commands below.
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
The Docker run command starts a container in detached mode (-d) and maps port 5000 of the host to port 5000 of the container.
```bash
docker run -d -p 5000:5000 <your-image-name>
```
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/django/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,51 @@
#### Requirements
- Python 3.8 or newer
&nbsp;
### Step 1 : Add OpenTelemetry dependencies
In your `requirements.txt` file, add these two OpenTelemetry dependencies:
```bash
opentelemetry-distro==0.43b0
opentelemetry-exporter-otlp==1.22.0
```
&nbsp;
### Step 2 : Dockerize your application
Update your dockerfile along with OpenTelemetry instructions as shown below:
```bash
...
# Install any needed packages specified in requirements.txt
# And install OpenTelemetry packages
RUN pip install --no-cache-dir -r requirements.txt
RUN opentelemetry-bootstrap --action=install
# (Optional) Make port 5000 available to the world outside this container (You can choose your own port for this)
EXPOSE 5000
# Set environment variables for OpenTelemetry
ENV OTEL_RESOURCE_ATTRIBUTES=service.name={{MYAPP}}
ENV OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.{REGION}.signoz.cloud:443
ENV OTEL_EXPORTER_OTLP_HEADERS=signoz-access-token={{SIGNOZ_INGESTION_KEY}}
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# Run app.py with OpenTelemetry instrumentation when the container launches
CMD ["opentelemetry-instrument", "<your_run_command>"]
...
```
- <your_run_command> can be `python3 app.py`

View File

@ -0,0 +1,29 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
The Docker run command starts a container in detached mode (-d) and maps port 5000 of the host to port 5000 of the container.
```bash
docker run -d -p 5000:5000 <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/falcon/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,56 @@
&nbsp;
After setting up the Otel collector agent, follow the steps below to Dockerize your Python Application
#### Requirements
- Python 3.8 or newer
&nbsp;
### Step 1 : Add OpenTelemetry dependencies
In your `requirements.txt` file, add these two OpenTelemetry dependencies:
```bash
opentelemetry-distro==0.43b0
opentelemetry-exporter-otlp==1.22.0
```
&nbsp;
### Step 2 : Dockerize your application
Update your Dockerfile along with OpenTelemetry instructions as shown below:
```bash
...
# Install any needed packages specified in requirements.txt
# And install OpenTelemetry packages
RUN pip install --no-cache-dir -r requirements.txt
RUN opentelemetry-bootstrap --action=install
# (Optional) Make port 5000 available to the world outside this container (You can choose your own port for this)
EXPOSE 5000
# Set environment variables for OpenTelemetry
ENV OTEL_RESOURCE_ATTRIBUTES=service.name={{MYAPP}}
ENV OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# Run app.py with OpenTelemetry instrumentation when the container launches
CMD ["opentelemetry-instrument", "<your_run_command>"]
...
```
- <your_run_command> can be `python3 app.py`

View File

@ -0,0 +1,25 @@
Once you update your Dockerfile, you can build and run it using the commands below.
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
The Docker run command starts a container in detached mode (-d) and maps port 5000 of the host to port 5000 of the container.
```bash
docker run -d -p 5000:5000 <your-image-name>
```
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/falcon/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,51 @@
#### Requirements
- Python 3.8 or newer
&nbsp;
### Step 1 : Add OpenTelemetry dependencies
In your `requirements.txt` file, add these two OpenTelemetry dependencies:
```bash
opentelemetry-distro==0.43b0
opentelemetry-exporter-otlp==1.22.0
```
&nbsp;
### Step 2 : Dockerize your application
Update your dockerfile along with OpenTelemetry instructions as shown below:
```bash
...
# Install any needed packages specified in requirements.txt
# And install OpenTelemetry packages
RUN pip install --no-cache-dir -r requirements.txt
RUN opentelemetry-bootstrap --action=install
# (Optional) Make port 5000 available to the world outside this container (You can choose your own port for this)
EXPOSE 5000
# Set environment variables for OpenTelemetry
ENV OTEL_RESOURCE_ATTRIBUTES=service.name={{MYAPP}}
ENV OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.{REGION}.signoz.cloud:443
ENV OTEL_EXPORTER_OTLP_HEADERS=signoz-access-token={{SIGNOZ_INGESTION_KEY}}
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# Run app.py with OpenTelemetry instrumentation when the container launches
CMD ["opentelemetry-instrument", "<your_run_command>"]
...
```
- <your_run_command> can be `python3 app.py` or `python manage.py runserver --noreload`

View File

@ -0,0 +1,29 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
The Docker run command starts a container in detached mode (-d) and maps port 5000 of the host to port 5000 of the container.
```bash
docker run -d -p 5000:5000 <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/fastapi/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,56 @@
&nbsp;
After setting up the Otel collector agent, follow the steps below to Dockerize your Python Application
#### Requirements
- Python 3.8 or newer
&nbsp;
### Step 1 : Add OpenTelemetry dependencies
In your `requirements.txt` file, add these two OpenTelemetry dependencies:
```bash
opentelemetry-distro==0.43b0
opentelemetry-exporter-otlp==1.22.0
```
&nbsp;
### Step 2 : Dockerize your application
Update your Dockerfile along with OpenTelemetry instructions as shown below:
```bash
...
# Install any needed packages specified in requirements.txt
# And install OpenTelemetry packages
RUN pip install --no-cache-dir -r requirements.txt
RUN opentelemetry-bootstrap --action=install
# (Optional) Make port 5000 available to the world outside this container (You can choose your own port for this)
EXPOSE 5000
# Set environment variables for OpenTelemetry
ENV OTEL_RESOURCE_ATTRIBUTES=service.name={{MYAPP}}
ENV OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# Run app.py with OpenTelemetry instrumentation when the container launches
CMD ["opentelemetry-instrument", "<your_run_command>"]
...
```
- <your_run_command> can be `python3 app.py` or `python manage.py runserver --noreload`

View File

@ -0,0 +1,25 @@
Once you update your Dockerfile, you can build and run it using the commands below.
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
The Docker run command starts a container in detached mode (-d) and maps port 5000 of the host to port 5000 of the container.
```bash
docker run -d -p 5000:5000 <your-image-name>
```
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/fastapi/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,50 @@
#### Requirements
- Python 3.8 or newer
&nbsp;
### Step 1 : Add OpenTelemetry dependencies
In your `requirements.txt` file, add these two OpenTelemetry dependencies:
```bash
opentelemetry-distro==0.43b0
opentelemetry-exporter-otlp==1.22.0
```
&nbsp;
### Step 2 : Dockerize your application
Update your dockerfile along with OpenTelemetry instructions as shown below:
```bash
...
# Install any needed packages specified in requirements.txt
# And install OpenTelemetry packages
RUN pip install --no-cache-dir -r requirements.txt
RUN opentelemetry-bootstrap --action=install
#(Optional) Make port 5000 available to the world outside this container (You can choose your own port for this)
EXPOSE 5000
# Set environment variables for OpenTelemetry
ENV OTEL_RESOURCE_ATTRIBUTES=service.name={{MYAPP}}
ENV OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.{REGION}.signoz.cloud:443
ENV OTEL_EXPORTER_OTLP_HEADERS=signoz-access-token={{SIGNOZ_INGESTION_KEY}}
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# Run app.py with OpenTelemetry instrumentation when the container launches
CMD ["opentelemetry-instrument", "<your_run_command>"]
...
```
- <your_run_command> can be `python3 app.py` or `flask run`

View File

@ -0,0 +1,29 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
The Docker run command starts a container in detached mode (-d) and maps port 5000 of the host to port 5000 of the container.
```bash
docker run -d -p 5000:5000 <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/flask/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,56 @@
&nbsp;
After setting up the Otel collector agent, follow the steps below to Dockerize your Python Application
#### Requirements
- Python 3.8 or newer
&nbsp;
### Step 1 : Add OpenTelemetry dependencies
In your `requirements.txt` file, add these two OpenTelemetry dependencies:
```bash
opentelemetry-distro==0.43b0
opentelemetry-exporter-otlp==1.22.0
```
&nbsp;
### Step 2 : Dockerize your application
Update your Dockerfile along with OpenTelemetry instructions as shown below:
```bash
...
# Install any needed packages specified in requirements.txt
# And install OpenTelemetry packages
RUN pip install --no-cache-dir -r requirements.txt
RUN opentelemetry-bootstrap --action=install
# (Optional) Make port 5000 available to the world outside this container (You can choose your own port for this)
EXPOSE 5000
# Set environment variables for OpenTelemetry
ENV OTEL_RESOURCE_ATTRIBUTES=service.name={{MYAPP}}
ENV OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# Run app.py with OpenTelemetry instrumentation when the container launches
CMD ["opentelemetry-instrument", "<your_run_command>"]
...
```
- <your_run_command> can be `python3 app.py` or `flask run`

View File

@ -0,0 +1,25 @@
Once you update your Dockerfile, you can build and run it using the commands below.
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
The Docker run command starts a container in detached mode (-d) and maps port 5000 of the host to port 5000 of the container.
```bash
docker run -d -p 5000:5000 <your-image-name>
```
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/flask/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,51 @@
#### Requirements
- Python 3.8 or newer
&nbsp;
### Step 1 : Add OpenTelemetry dependencies
In your `requirements.txt` file, add these two OpenTelemetry dependencies:
```bash
opentelemetry-distro==0.43b0
opentelemetry-exporter-otlp==1.22.0
```
&nbsp;
### Step 2 : Dockerize your application
Update your dockerfile along with OpenTelemetry instructions as shown below:
```bash
...
# Install any needed packages specified in requirements.txt
# And install OpenTelemetry packages
RUN pip install --no-cache-dir -r requirements.txt
RUN opentelemetry-bootstrap --action=install
# (Optional) Make port 5000 available to the world outside this container (You can choose your own port for this)
EXPOSE 5000
# Set environment variables for OpenTelemetry
ENV OTEL_RESOURCE_ATTRIBUTES=service.name={{MYAPP}}
ENV OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.{REGION}.signoz.cloud:443
ENV OTEL_EXPORTER_OTLP_HEADERS=signoz-access-token={{SIGNOZ_INGESTION_KEY}}
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# Run app.py with OpenTelemetry instrumentation when the container launches
CMD ["opentelemetry-instrument", "<your_run_command>"]
...
```
- <your_run_command> can be `python3 app.py`

View File

@ -0,0 +1,29 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
The Docker run command starts a container in detached mode (-d) and maps port 5000 of the host to port 5000 of the container.
```bash
docker run -d -p 5000:5000 <your-image-name>
```
&nbsp;
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/python/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,56 @@
&nbsp;
After setting up the Otel collector agent, follow the steps below to Dockerize your Python Application
#### Requirements
- Python 3.8 or newer
&nbsp;
### Step 1 : Add OpenTelemetry dependencies
In your `requirements.txt` file, add these two OpenTelemetry dependencies:
```bash
opentelemetry-distro==0.43b0
opentelemetry-exporter-otlp==1.22.0
```
&nbsp;
### Step 2 : Dockerize your application
Update your Dockerfile along with OpenTelemetry instructions as shown below:
```bash
...
# Install any needed packages specified in requirements.txt
# And install OpenTelemetry packages
RUN pip install --no-cache-dir -r requirements.txt
RUN opentelemetry-bootstrap --action=install
# (Optional) Make port 5000 available to the world outside this container (You can choose your own port for this)
EXPOSE 5000
# Set environment variables for OpenTelemetry
ENV OTEL_RESOURCE_ATTRIBUTES=service.name={{MYAPP}}
ENV OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# Run app.py with OpenTelemetry instrumentation when the container launches
CMD ["opentelemetry-instrument", "<your_run_command>"]
...
```
- <your_run_command> can be `python3 app.py`

View File

@ -0,0 +1,25 @@
Once you update your Dockerfile, you can build and run it using the commands below.
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
The Docker run command starts a container in detached mode (-d) and maps port 5000 of the host to port 5000 of the container.
```bash
docker run -d -p 5000:5000 <your-image-name>
```
**Note**
If you encounter any difficulties, please consult the [troubleshooting section](https://signoz.io/docs/instrumentation/python/#troubleshooting-your-installation) for assistance.

View File

@ -0,0 +1,54 @@
&nbsp;
### Step 1: Install dependencies
Install dependencies related to OpenTelemetry SDK and exporter using gem
```bash
gem install opentelemetry-sdk
gem install opentelemetry-exporter-otlp
gem install opentelemetry-instrumentation-all
```
&nbsp;
Include the required packages into your gemfile
```bash
gem 'opentelemetry-sdk'
gem 'opentelemetry-exporter-otlp'
gem 'opentelemetry-instrumentation-all'
```
&nbsp;
Run the bundle install command:
```bash
bundle install
```
&nbsp;
### Step 2: Initialize the OpenTelemetry SDK
Initialize the otel sdk by adding below lines to `config/environment.rb` of your Ruby on Rails application
```bash
require 'opentelemetry/sdk'
require_relative 'application'
OpenTelemetry::SDK.configure do |c|
c.use_all
end
Rails.application.initialize!
```
&nbsp;
### Step 3: Dockerize your application
Update your dockerfile to include the environment variables:
```bash
...
# Set environment variables
ENV OTEL_EXPORTER=otlp \
OTEL_SERVICE_NAME={{MYAPP}} \
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.{{REGION}}.signoz.cloud:443 \
OTEL_EXPORTER_OTLP_HEADERS=signoz-access-token={{SIGNOZ_INGESTION_KEY}}
...
```

View File

@ -0,0 +1,21 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```

View File

@ -0,0 +1,12 @@
## Setup OpenTelemetry Binary as an agent
&nbsp;
As a first step, you should install the OTel collector Binary according to the instructions provided on [this link](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
&nbsp;
Once you are done setting up the OTel collector binary, you can follow the next steps.
&nbsp;

View File

@ -0,0 +1,57 @@
&nbsp;
After setting up the Otel collector agent, follow the steps below to instrument your Ruby On Rails Application
&nbsp;
### Step 1: Install dependencies
Install dependencies related to OpenTelemetry SDK and exporter using gem
```bash
gem install opentelemetry-sdk
gem install opentelemetry-exporter-otlp
gem install opentelemetry-instrumentation-all
```
&nbsp;
Include the required packages into your gemfile
```bash
gem 'opentelemetry-sdk'
gem 'opentelemetry-exporter-otlp'
gem 'opentelemetry-instrumentation-all'
```
&nbsp;
Run the bundle install command:
```bash
bundle install
```
&nbsp;
### Step 2: Initialize the OpenTelemetry SDK
Initialize the otel sdk by adding below lines to `config/environment.rb` of your Ruby on Rails application
```bash
require 'opentelemetry/sdk'
require_relative 'application'
OpenTelemetry::SDK.configure do |c|
c.use_all
end
Rails.application.initialize!
```
&nbsp;
### Step 3: Dockerize your application
Update your dockerfile to include the environment variables:
```bash
...
# Set environment variables
ENV OTEL_EXPORTER=otlp \
OTEL_SERVICE_NAME={{MYAPP}} \
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
...
```

View File

@ -0,0 +1,21 @@
Once you update your Dockerfile, you can build and run it using the commands below.
&nbsp;
### Step 1: Build your dockerfile
Build your docker image
```bash
docker build -t <your-image-name> .
```
- `<your-image-name>` is the name of your Docker Image
&nbsp;
### Step 2: Run your docker image
```bash
docker run <your-image-name>
```

View File

@ -0,0 +1,146 @@
&nbsp;
### Step 1: Add dependencies
Add these crates just below the `[dependencies]` section of your `cargo.toml` file
```rust
opentelemetry = { version = "0.18.0", features = ["rt-tokio", "metrics", "trace"] }
opentelemetry-otlp = { version = "0.11.0", features = ["trace", "metrics"] }
opentelemetry-semantic-conventions = { version = "0.10.0" }
opentelemetry-proto = { version = "0.1.0"}
tokio = { version = "1", features = ["full"] }
tonic = { version = "0.8.2", features = ["tls-roots"] }
dotenv = "0.15.0"
```
&nbsp;
Use the above crates in entry point of your Rust application, which is generally your `main.rs` file
```rust
use dotenv::dotenv;
use opentelemetry::global::shutdown_tracer_provider;
use opentelemetry::sdk::Resource;
use opentelemetry::trace::TraceError;
use opentelemetry::{
global, sdk::trace as sdktrace,
trace::{TraceContextExt, Tracer},
Context, Key, KeyValue,
};
use opentelemetry_otlp::WithExportConfig;
use tonic::metadata::{MetadataMap, MetadataValue};
```
&nbsp;
### Step 2: Initialize tracer and create env file
Add `init_tracer` function to your `main.rs` file. It initializes an OpenTelemetry tracer with the OpenTelemetry OTLP exporter which is sending data to SigNoz Cloud.
```rust
fn init_tracer() -> Result<sdktrace::Tracer, TraceError> {
let signoz_access_token = std::env::var("SIGNOZ_ACCESS_TOKEN").expect("SIGNOZ_ACCESS_TOKEN not set");
let mut metadata = MetadataMap::new();
metadata.insert(
"signoz-access-token",
MetadataValue::from_str(&signoz_access_token).unwrap(),
);
opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(
opentelemetry_otlp::new_exporter()
.tonic()
.with_metadata(metadata)
.with_endpoint(std::env::var("SIGNOZ_ENDPOINT").expect("SIGNOZ_ENDPOINT not set")),
)
.with_trace_config(
sdktrace::config().with_resource(Resource::new(vec![
KeyValue::new(
opentelemetry_semantic_conventions::resource::SERVICE_NAME,
std::env::var("APP_NAME").expect("APP_NAME not set"),
),
])),
)
.install_batch(opentelemetry::runtime::Tokio)
}
```
After adding the above function in your `main.rs` file, create an `.env` file in root of your app. The structure could look like this :
```bash
project_root/
|-- Cargo.toml
|-- src/
| |-- main.rs
|-- .env
```
In your environment file, paste the below variables which will be used in the next steps.
```rust
PORT=3000 // If it is a web app pass port or else you can ignore this variable
APP_NAME={{MYAPP}}
SIGNOZ_ENDPOINT=https://ingest.{{REGION}}.signoz.cloud:443/v1/traces
SIGNOZ_ACCESS_TOKEN={{SIGNOZ_INGESTION_KEY}}
```
### Step 3: Add OpenTelemetry instrumentation
Call the `init_tracer` function inside `main()` at starting so that as soon as your rust application starts, tracer will be available globally.
```rust
dotenv().ok();
let _ = init_tracer();
```
Modify your `main()` function from
```rust
fn main(){
//rest of the code
}
```
&nbsp;
to
```rust
#[tokio::main]
async fn main() {
//rest of the code
}
```
Add the below code block within a function or a section of your code where you're setting up and using the tracer for distributed tracing. After adding the below code block you can send traces to SigNoz Cloud
```rust
let tracer = global::tracer("global_tracer");
let _cx = Context::new();
tracer.in_span("operation", |cx| {
let span = cx.span();
span.set_attribute(Key::new("KEY").string("value"));
span.add_event(
format!("Operations"),
vec![
Key::new("SigNoz is").string("working!"),
],
);
});
shutdown_tracer_provider()
```
The above code block will create a span named operation which sets an attribute and an event to it saying "SigNoz is working!".
&nbsp;
### Step 4: Dockerize your application
Update your Dockerfile to include the `.env` file created above
```bash
...
# Copy your .env file
COPY .env .
...
```

Some files were not shown because too many files have changed in this diff Show More