-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4797 from SigNoz/docker-instructions
Docker instructions
- Loading branch information
Showing
111 changed files
with
4,523 additions
and
16 deletions.
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
...net/md-docs/Docker/QuickStart/dotnet-docker-quickStart-instrumentApplication.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
|
||
| ||
|
||
Here’s 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, we’re 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:/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"] | ||
``` |
21 changes: 21 additions & 0 deletions
21
...APM/Dotnet/md-docs/Docker/QuickStart/dotnet-docker-quickStart-runApplication.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
| ||
|
||
### Step 2: Run your docker image | ||
|
||
```bash | ||
docker run <your-image-name> | ||
``` |
12 changes: 12 additions & 0 deletions
12
...et/md-docs/Docker/Recommended/dotnet-docker-recommended-installOtelCollector.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## Setup OpenTelemetry Binary as an agent | ||
|
||
| ||
|
||
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/). | ||
|
||
| ||
|
||
Once you are done setting up the OTel collector binary, you can follow the next steps. | ||
|
||
| ||
|
101 changes: 101 additions & 0 deletions
101
...t/md-docs/Docker/Recommended/dotnet-docker-recommended-instrumentApplication.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
After setting up the Otel collector agent, follow the steps below to instrument your .NET Application | ||
|
||
| ||
| ||
|
||
### 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 | ||
``` | ||
|
||
| ||
|
||
### 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. | ||
|
||
| ||
|
||
Here’s 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(); | ||
``` | ||
| ||
|
||
The OpenTelemetry.Exporter.Options get or set the target to which the exporter is going to send traces. Here, we’re 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:/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 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"] | ||
``` |
21 changes: 21 additions & 0 deletions
21
...M/Dotnet/md-docs/Docker/Recommended/dotnet-docker-recommended-runApplication.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
| ||
|
||
### Step 2: Run your docker image | ||
|
||
```bash | ||
docker run <your-image-name> | ||
``` |
67 changes: 67 additions & 0 deletions
67
...xir/md-docs/Docker/QuickStart/elixir-docker-quickStart-instrumentApplication.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
| ||
|
||
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"} | ||
``` | ||
| ||
|
||
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]) | ||
``` | ||
| ||
|
||
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 | ||
``` | ||
|
||
| ||
|
||
### 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}} } | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
| ||
|
||
### 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. |
25 changes: 25 additions & 0 deletions
25
...APM/Elixir/md-docs/Docker/QuickStart/elixir-docker-quickStart-runApplication.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
| ||
|
||
### Step 2: Run your docker image | ||
|
||
```bash | ||
docker run <your-image-name> | ||
``` | ||
|
||
| ||
|
||
To see some examples for instrumented applications, you can checkout [this link](https://signoz.io/docs/instrumentation/elixir/#sample-examples) |
12 changes: 12 additions & 0 deletions
12
...ir/md-docs/Docker/Recommended/elixir-docker-recommended-installOtelCollector.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## Setup OpenTelemetry Binary as an agent | ||
|
||
| ||
|
||
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/). | ||
|
||
| ||
|
||
Once you are done setting up the OTel collector binary, you can follow the next steps. | ||
|
||
| ||
|
Oops, something went wrong.