docs: updated APM docs (#3548)

* docs: updated APM docs

* feat: signoz cloud - update logs management and infra monitoring docs

---------

Co-authored-by: Yunus A M <myounis.ar@live.com>
This commit is contained in:
Ankit Anand 2023-09-14 01:43:49 +05:30 committed by GitHub
parent ed809474d6
commit 2fc82ffa59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 1954 additions and 1078 deletions

View File

@ -1,7 +1,6 @@
## Send Traces to SigNoz Cloud ## Send Traces to SigNoz Cloud
<Tabs> ### Application on VMs
<TabItem value="vm" label="VM" default>
From VMs, there are two ways to send data to SigNoz Cloud. From VMs, there are two ways to send data to SigNoz Cloud.
@ -11,138 +10,148 @@ From VMs, there are two ways to send data to SigNoz Cloud.
#### **Send traces directly to SigNoz Cloud** #### **Send traces directly to SigNoz Cloud**
1. **Install Dependencies**<br></br> 1. **Install Dependencies**<br></br>
Dependencies related to OpenTelemetry exporter and SDK have to be installed first. Note that we are assuming you are using `gin` request router. If you are using other request routers, check out the [corresponding package](#request-routers). Dependencies related to OpenTelemetry exporter and SDK have to be installed first. Note that we are assuming you are using `gin` request router. If you are using other request routers, check out the [corresponding package](#request-routers).
Run the below commands after navigating to the application source folder: Run the below commands after navigating to the application source folder:
```bash ```bash
go get go.opentelemetry.io/otel \ go get go.opentelemetry.io/otel \
go.opentelemetry.io/otel/trace \ go.opentelemetry.io/otel/trace \
go.opentelemetry.io/otel/sdk \ go.opentelemetry.io/otel/sdk \
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin \ 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 \
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
``` ```
2. **Declare environment variables for configuring OpenTelemetry**<br></br> 2. **Declare environment variables for configuring OpenTelemetry**<br></br>
Declare the following global variables in `main.go` which we will use to configure OpenTelemetry: Declare the following global variables in `main.go` which we will use to configure OpenTelemetry:
```bash ```bash
var ( var (
serviceName = os.Getenv("SERVICE_NAME") serviceName = os.Getenv("SERVICE_NAME")
collectorURL = os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT") collectorURL = os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT")
insecure = os.Getenv("INSECURE_MODE") insecure = os.Getenv("INSECURE_MODE")
) )
``` ```
3. **Instrument your Go application with OpenTelemetry**<br></br> 3. **Instrument your Go application with OpenTelemetry**<br></br>
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. 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.
```go
import (
.....
```go "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"
import ( "go.opentelemetry.io/otel/sdk/resource"
..... sdktrace "go.opentelemetry.io/otel/sdk/trace"
)
"github.com/gin-gonic/gin" func initTracer() func(context.Context) error {
"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" var secureOption otlptracegrpc.Option
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)
func initTracer() func(context.Context) error { if strings.ToLower(insecure) == "false" || insecure == "0" || strings.ToLower(insecure) == "f" {
secureOption = otlptracegrpc.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, ""))
} else {
secureOption = otlptracegrpc.WithInsecure()
}
var secureOption otlptracegrpc.Option exporter, err := otlptrace.New(
context.Background(),
otlptracegrpc.NewClient(
secureOption,
otlptracegrpc.WithEndpoint(collectorURL),
),
)
if strings.ToLower(insecure) == "false" || insecure == "0" || strings.ToLower(insecure) == "f" { if err != nil {
secureOption = otlptracegrpc.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, "")) log.Fatalf("Failed to create exporter: %v", err)
} else { }
secureOption = otlptracegrpc.WithInsecure() resources, err := resource.New(
} context.Background(),
resource.WithAttributes(
exporter, err := otlptrace.New( attribute.String("service.name", serviceName),
context.Background(), attribute.String("library.language", "go"),
otlptracegrpc.NewClient( ),
secureOption, )
otlptracegrpc.WithEndpoint(collectorURL), if err != nil {
), log.Fatalf("Could not set resources: %v", err)
) }
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
}
```
otel.SetTracerProvider(
sdktrace.NewTracerProvider(
sdktrace.WithSampler(sdktrace.AlwaysSample()),
sdktrace.WithBatcher(exporter),
sdktrace.WithResource(resources),
),
)
return exporter.Shutdown
}
```
4. **Initialize the tracer in main.go**<br></br> 4. **Initialize the tracer in main.go**<br></br>
Modify the main function to initialise the tracer in `main.go`. Initiate the tracer at the very beginning of our main function. Modify the main function to initialise the tracer in `main.go`. Initiate the tracer at the very beginning of our main function.
```go
func main() { ```go
cleanup := initTracer() func main() {
defer cleanup(context.Background()) cleanup := initTracer()
defer cleanup(context.Background())
......
} ......
``` }
```
5. **Add the OpenTelemetry Gin middleware**<br></br> 5. **Add the OpenTelemetry Gin middleware**<br></br>
Configure Gin to use the middleware by adding the following lines in `main.go`. Configure Gin to use the middleware by adding the following lines in `main.go`.
```go ```go
import ( import (
.... ....
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin" "go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
) )
func main() { func main() {
...... ......
r := gin.Default() r := gin.Default()
r.Use(otelgin.Middleware(serviceName)) r.Use(otelgin.Middleware(serviceName))
...... ......
} }
``` ```
6. **Set environment variables and run your Go Gin application**<br></br> 6. **Set environment variables and run your Go Gin application**<br></br>
The run command must have some environment variables to send data to SigNoz cloud. The run command: The run command must have some environment variables to send data to SigNoz cloud. The run command:
```bash
SERVICE_NAME=goApp INSECURE_MODE=false OTEL_EXPORTER_OTLP_HEADERS=signoz-access-token=<SIGNOZ-INGESTION-TOKEN> OTEL_EXPORTER_OTLP_ENDPOINT=ingest.{region}.signoz.cloud:443 go run main.go
```
```bash We can replace the placeholders based on our environment.
SERVICE_NAME=goApp INSECURE_MODE=false OTEL_EXPORTER_OTLP_HEADERS=signoz-access-token=<SIGNOZ-INGESTION-TOKEN> OTEL_EXPORTER_OTLP_ENDPOINT=ingest.{region}.signoz.cloud:443 go run main.go
``` `SERVICE_NAME`: goGinApp (you can name it whatever you want)
We can replace the placeholders based on our environment. `OTEL_EXPORTER_OTLP_HEADERS`: `signoz-access-token=<SIGNOZ-INGESTION-TOKEN>`. Update `<SIGNOZ-INGESTION-TOKEN>` with the ingestion token provided by SigNoz
`OTEL_EXPORTER_OTLP_ENDPOINT`: ingest.{region}.signoz.cloud:443. Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
`SERVICE_NAME`: goGinApp (you can name it whatever you want)
US - ingest.us.signoz.cloud:443 <br></br>
`OTEL_EXPORTER_OTLP_HEADERS`: `signoz-access-token=<SIGNOZ-INGESTION-TOKEN>`. Update `<SIGNOZ-INGESTION-TOKEN>` with the ingestion token provided by SigNoz IN - ingest.in.signoz.cloud:443 <br></br>
`OTEL_EXPORTER_OTLP_ENDPOINT`: ingest.{region}.signoz.cloud:443. Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table. EU - ingest.eu.signoz.cloud:443 <br></br>
| Region | Endpoint |
| ------ | -------------------------- |
| US | ingest.us.signoz.cloud:443 |
| IN | ingest.in.signoz.cloud:443 |
| EU | ingest.eu.signoz.cloud:443 |
--- ---
@ -153,35 +162,38 @@ OTel Collector binary helps to collect logs, hostmetrics, resource and infra att
You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Golang application. You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Golang application.
1. **Install Dependencies**<br></br> 1. **Install Dependencies**<br></br>
Dependencies related to OpenTelemetry exporter and SDK have to be installed first. Note that we are assuming you are using `gin` request router. If you are using other request routers, check out the [corresponding package](#request-routers). Dependencies related to OpenTelemetry exporter and SDK have to be installed first. Note that we are assuming you are using `gin` request router. If you are using other request routers, check out the [corresponding package](#request-routers).
Run the below commands after navigating to the application source folder: Run the below commands after navigating to the application source folder:
```bash ```bash
go get go.opentelemetry.io/otel \ go get go.opentelemetry.io/otel \
go.opentelemetry.io/otel/trace \ go.opentelemetry.io/otel/trace \
go.opentelemetry.io/otel/sdk \ go.opentelemetry.io/otel/sdk \
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin \ 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 \
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
``` ```
2. **Declare environment variables for configuring OpenTelemetry**<br></br> 2. **Declare environment variables for configuring OpenTelemetry**<br></br>
Declare the following global variables in `main.go` which we will use to configure OpenTelemetry: Declare the following global variables in `main.go` which we will use to configure OpenTelemetry:
```go ```go
var ( var (
serviceName = os.Getenv("SERVICE_NAME") serviceName = os.Getenv("SERVICE_NAME")
collectorURL = os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT") collectorURL = os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT")
insecure = os.Getenv("INSECURE_MODE") insecure = os.Getenv("INSECURE_MODE")
) )
``` ```
3. **Instrument your Go application with OpenTelemetry**<br></br> 3. **Instrument your Go application with OpenTelemetry**<br></br>
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. 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.
```go ```go
import ( import (
..... .....
@ -236,84 +248,90 @@ You can find instructions to install OTel Collector binary [here](https://signoz
) )
return exporter.Shutdown return exporter.Shutdown
} }
```
4. **Initialize the tracer in main.go**<br></br> 4. **Initialize the tracer in main.go**<br></br>
Modify the main function to initialise the tracer in `main.go`. Initiate the tracer at the very beginning of our main function. Modify the main function to initialise the tracer in `main.go`. Initiate the tracer at the very beginning of our main function.
```go
func main() { ```go
cleanup := initTracer() func main() {
defer cleanup(context.Background()) cleanup := initTracer()
defer cleanup(context.Background())
......
} ......
``` }
```
5. **Add the OpenTelemetry Gin middleware**<br></br> 5. **Add the OpenTelemetry Gin middleware**<br></br>
Configure Gin to use the middleware by adding the following lines in `main.go`. Configure Gin to use the middleware by adding the following lines in `main.go`.
```go
import ( ```go
.... import (
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin" ....
) "go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
)
func main() {
...... func main() {
r := gin.Default() ......
r.Use(otelgin.Middleware(serviceName)) r := gin.Default()
...... r.Use(otelgin.Middleware(serviceName))
} ......
``` }
```
6. **Set environment variables and run your Go Gin application**<br></br> 6. **Set environment variables and run your Go Gin application**<br></br>
The run command must have some environment variables to send data to SigNoz. The run command: The run command must have some environment variables to send data to SigNoz. The run command:
```bash
SERVICE_NAME=goGinApp INSECURE_MODE=true OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 go run main.go
```
If you want to update your `service_name`, you can modify the `SERVICE_NAME` variable.<br></br>
`SERVICE_NAME`: goGinApp (you can name it whatever you want)
```bash ---
SERVICE_NAME=goGinApp INSECURE_MODE=true OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 go run main.go
```
If you want to update your `service_name`, you can modify the `SERVICE_NAME` variable.<br></br> ### Applications Deployed on Kubernetes
`SERVICE_NAME`: goGinApp (you can name it whatever you want)
7. You can validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces).
</TabItem>
<TabItem value="k8s" label="Kubernetes">
For Golang application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](/docs/tutorial/kubernetes-infra-metrics/). For Golang application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](/docs/tutorial/kubernetes-infra-metrics/).
Once you have set up OTel Collector agent, you can proceed with OpenTelemetry Golang instrumentation by following the below steps: Once you have set up OTel Collector agent, you can proceed with OpenTelemetry Golang instrumentation by following the below steps:
1. **Install Dependencies**<br></br> 1. **Install Dependencies**<br></br>
Dependencies related to OpenTelemetry exporter and SDK have to be installed first. Note that we are assuming you are using `gin` request router. If you are using other request routers, check out the [corresponding package](#request-routers). Dependencies related to OpenTelemetry exporter and SDK have to be installed first. Note that we are assuming you are using `gin` request router. If you are using other request routers, check out the [corresponding package](#request-routers).
Run the below commands after navigating to the application source folder: Run the below commands after navigating to the application source folder:
```bash ```bash
go get go.opentelemetry.io/otel \ go get go.opentelemetry.io/otel \
go.opentelemetry.io/otel/trace \ go.opentelemetry.io/otel/trace \
go.opentelemetry.io/otel/sdk \ go.opentelemetry.io/otel/sdk \
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin \ 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 \
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
``` ```
2. **Declare environment variables for configuring OpenTelemetry**<br></br> 2. **Declare environment variables for configuring OpenTelemetry**<br></br>
Declare the following global variables in `main.go` which we will use to configure OpenTelemetry: Declare the following global variables in `main.go` which we will use to configure OpenTelemetry:
```go ```go
var ( var (
serviceName = os.Getenv("SERVICE_NAME") serviceName = os.Getenv("SERVICE_NAME")
collectorURL = os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT") collectorURL = os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT")
insecure = os.Getenv("INSECURE_MODE") insecure = os.Getenv("INSECURE_MODE")
) )
``` ```
3. **Instrument your Go application with OpenTelemetry**<br></br> 3. **Instrument your Go application with OpenTelemetry**<br></br>
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. 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.
```go ```go
import ( import (
..... .....
@ -368,45 +386,45 @@ Once you have set up OTel Collector agent, you can proceed with OpenTelemetry Go
) )
return exporter.Shutdown return exporter.Shutdown
} }
```
4. **Initialize the tracer in main.go**<br></br> 4. **Initialize the tracer in main.go**<br></br>
Modify the main function to initialise the tracer in `main.go`. Initiate the tracer at the very beginning of our main function. Modify the main function to initialise the tracer in `main.go`. Initiate the tracer at the very beginning of our main function.
```go
func main() { ```go
cleanup := initTracer() func main() {
defer cleanup(context.Background()) cleanup := initTracer()
defer cleanup(context.Background())
......
} ......
``` }
```
5. **Add the OpenTelemetry Gin middleware**<br></br> 5. **Add the OpenTelemetry Gin middleware**<br></br>
Configure Gin to use the middleware by adding the following lines in `main.go`. Configure Gin to use the middleware by adding the following lines in `main.go`.
```go
import ( ```go
.... import (
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin" ....
) "go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
)
func main() {
...... func main() {
r := gin.Default() ......
r.Use(otelgin.Middleware(serviceName)) r := gin.Default()
...... r.Use(otelgin.Middleware(serviceName))
} ......
``` }
```
6. **Set environment variables and run your Go Gin application**<br></br> 6. **Set environment variables and run your Go Gin application**<br></br>
The run command must have some environment variables to send data to SigNoz. The run command: The run command must have some environment variables to send data to SigNoz. The run command:
```bash ```bash
SERVICE_NAME=goGinApp INSECURE_MODE=true OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 go run main.go SERVICE_NAME=goGinApp INSECURE_MODE=true OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 go run main.go
``` ```
If you want to update your `service_name`, you can modify the `SERVICE_NAME` variable.<br></br> If you want to update your `service_name`, you can modify the `SERVICE_NAME` variable.<br></br>
`SERVICE_NAME`: goGinApp (you can name it whatever you want) `SERVICE_NAME`: goGinApp (you can name it whatever you want)
7. You can validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces).
</TabItem>
</Tabs>

View File

@ -1,9 +1,15 @@
## Requirements
Java 8 or higher
## Send Traces to SigNoz Cloud ## Send Traces to SigNoz Cloud
OpenTelemetry provides a handy Java JAR agent that can be attached to any Java 8+ application and dynamically injects bytecode to capture telemetry from a number of popular libraries and frameworks. OpenTelemetry provides a handy Java JAR agent that can be attached to any Java 8+ application and dynamically injects bytecode to capture telemetry from a number of popular libraries and frameworks.
Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud. Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud.
### Application on VMs
From VMs, there are two ways to send data to SigNoz Cloud. From VMs, there are two ways to send data to SigNoz Cloud.
- [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud) - [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud)
@ -33,11 +39,12 @@ java -javaagent:$PWD/opentelemetry-javaagent.jar -jar <my-app>.jar
Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table. Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
| Region | Endpoint | US - ingest.us.signoz.cloud:443 <br></br>
| ------ | -------------------------- |
| US | ingest.us.signoz.cloud:443 | IN - ingest.in.signoz.cloud:443 <br></br>
| IN | ingest.in.signoz.cloud:443 |
| EU | ingest.eu.signoz.cloud:443 | EU - ingest.eu.signoz.cloud:443 <br></br>
--- ---
@ -62,6 +69,10 @@ java -javaagent:$PWD/opentelemetry-javaagent.jar -jar <myapp>.jar
- `<myapp>` is the name of your application jar file - `<myapp>` is the name of your application jar file
- In case you download `opentelemetry-javaagent.jar` file in different directory than that of the project, replace `$PWD` with the path of the otel jar file. - In case you download `opentelemetry-javaagent.jar` file in different directory than that of the project, replace `$PWD` with the path of the otel jar file.
---
### Applications Deployed on Kubernetes
For Java application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](/docs/tutorial/kubernetes-infra-metrics/). For Java application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](/docs/tutorial/kubernetes-infra-metrics/).
Once you have set up OTel Collector agent, you can proceed with OpenTelemetry java instrumentation by following the below steps: Once you have set up OTel Collector agent, you can proceed with OpenTelemetry java instrumentation by following the below steps:
@ -73,7 +84,7 @@ Once you have set up OTel Collector agent, you can proceed with OpenTelemetry ja
``` ```
2. Run your application<br></br> 2. Run your application<br></br>
```bash ```bash
java -javaagent:$PWD/opentelemetry-javaagent.jar -jar <myapp>.jar java -javaagent:$PWD/opentelemetry-javaagent.jar -jar <myapp>.jar
``` ```
@ -82,5 +93,4 @@ Once you have set up OTel Collector agent, you can proceed with OpenTelemetry ja
- In case you download `opentelemetry-javaagent.jar` file in different directory than that of the project, replace `$PWD` with the path of the otel jar file. - In case you download `opentelemetry-javaagent.jar` file in different directory than that of the project, replace `$PWD` with the path of the otel jar file.
3. Make sure to dockerise your application along with OpenTelemetry instrumentation. 3. Make sure to dockerise your application along with OpenTelemetry instrumentation.
You can validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces).

View File

@ -1,7 +1,23 @@
## Send traces directly to SigNoz Cloud ## Requirements
Java 8 or higher
## Send Traces to SigNoz Cloud
OpenTelemetry provides a handy Java JAR agent that can be attached to any Java 8+ application and dynamically injects bytecode to capture telemetry from a number of popular libraries and frameworks.
Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud.
### Application on VMs
From VMs, there are two ways to send data to SigNoz Cloud.
- [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud)
- [Send traces via OTel Collector binary](#send-traces-via-otel-collector-binary) (recommended)
#### **Send traces directly to SigNoz Cloud**
OpenTelemetry Java agent can send traces directly to SigNoz Cloud. OpenTelemetry Java agent can send traces directly to SigNoz Cloud.
Step 1. Download otel java binary agent Step 1. Download otel java binary agent
```bash ```bash
@ -13,7 +29,7 @@ Step 2. Open the configuration file
```bash ```bash
vim /opt/jboss-eap-7.1/bin/standalone.conf vim /opt/jboss-eap-7.1/bin/standalone.conf
``` ```
Step 3. Update `JAVA_OPTS` environment variable Step 3. Update `JAVA_OPTS` environment variable
Update `JAVA_OPTS` environment variable with configurations required to send data to SigNoz cloud in your configuration file. Update `JAVA_OPTS` environment variable with configurations required to send data to SigNoz cloud in your configuration file.
@ -24,7 +40,6 @@ JAVA_OPTS="-javaagent:/path/opentelemetry-javaagent.jar
-Dotel.exporter.otlp.headers="signoz-access-token=SIGNOZ_INGESTION_KEY" -Dotel.exporter.otlp.headers="signoz-access-token=SIGNOZ_INGESTION_KEY"
-Dotel.resource.attributes="service.name=<app_name>"" -Dotel.resource.attributes="service.name=<app_name>""
``` ```
You need to replace the following things based on your environment:<br></br> You need to replace the following things based on your environment:<br></br>
- `path` - Update it to the path of your downloaded Java JAR agent.<br></br> - `path` - Update it to the path of your downloaded Java JAR agent.<br></br>
@ -33,18 +48,19 @@ You need to replace the following things based on your environment:<br></br>
Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table. Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
| Region | Endpoint |
| ------ | -------------------------- |
| US | ingest.us.signoz.cloud:443 |
| IN | ingest.in.signoz.cloud:443 |
| EU | ingest.eu.signoz.cloud:443 |
US - ingest.us.signoz.cloud:443 <br></br>
IN - ingest.in.signoz.cloud:443 <br></br>
EU - ingest.eu.signoz.cloud:443 <br></br>
Step 4. [Optional] Write the output/logs of standalone.sh script to a file nohup.out as a background thread Step 4. [Optional] Write the output/logs of standalone.sh script to a file nohup.out as a background thread
```bash ```bash
/opt/jboss-eap-7.1/bin/standalone.sh > /opt/jboss-eap-7.1/bin/nohup.out & /opt/jboss-eap-7.1/bin/standalone.sh > /opt/jboss-eap-7.1/bin/nohup.out &
``` ```
--- ---
#### **Send traces via OTel Collector binary** #### **Send traces via OTel Collector binary**
@ -54,11 +70,11 @@ OTel Collector binary helps to collect logs, hostmetrics, resource and infra att
You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Java application. You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Java application.
Step 1. Download OTel java binary agent<br></br> Step 1. Download OTel java binary agent<br></br>
```bash ```bash
wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
``` ```
Step 2. Open the configuration file Step 2. Open the configuration file
```bash ```bash
@ -74,9 +90,12 @@ JAVA_OPTS="-javaagent:/path/opentelemetry-javaagent.jar"
``` ```
where, where,
- `path` - Update it to the path of your downloaded Java JAR agent.<br></br> - `path` - Update it to the path of your downloaded Java JAR agent.<br></br>
---
### Applications Deployed on Kubernetes
For Java application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](/docs/tutorial/kubernetes-infra-metrics/). For Java application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](/docs/tutorial/kubernetes-infra-metrics/).
Once you have set up OTel Collector agent, you can proceed with OpenTelemetry java instrumentation by following the below steps: Once you have set up OTel Collector agent, you can proceed with OpenTelemetry java instrumentation by following the below steps:
@ -102,9 +121,7 @@ JAVA_OPTS="-javaagent:/path/opentelemetry-javaagent.jar"
``` ```
where, where,
- `path` - Update it to the path of your downloaded Java JAR agent.<br></br> - `path` - Update it to the path of your downloaded Java JAR agent.<br></br>
Step 4. Make sure to dockerise your application along with OpenTelemetry instrumentation.
You can validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces). Step 4. Make sure to dockerise your application along with OpenTelemetry instrumentation.

View File

@ -1,7 +1,23 @@
## Send traces directly to SigNoz Cloud ## Requirements
Java 8 or higher
## Send Traces to SigNoz Cloud
OpenTelemetry provides a handy Java JAR agent that can be attached to any Java 8+ application and dynamically injects bytecode to capture telemetry from a number of popular libraries and frameworks.
Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud.
### Application on VMs
From VMs, there are two ways to send data to SigNoz Cloud.
- [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud)
- [Send traces via OTel Collector binary](#send-traces-via-otel-collector-binary) (recommended)
#### **Send traces directly to SigNoz Cloud**
OpenTelemetry Java agent can send traces directly to SigNoz Cloud. OpenTelemetry Java agent can send traces directly to SigNoz Cloud.
Step 1. Download otel java binary agent Step 1. Download otel java binary agent
```bash ```bash
@ -16,17 +32,16 @@ OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=SIGNOZ_INGESTION_KEY" \
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.{region}.signoz.cloud:443 \ OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.{region}.signoz.cloud:443 \
java -javaagent:$PWD/opentelemetry-javaagent.jar -jar <my-app>.jar java -javaagent:$PWD/opentelemetry-javaagent.jar -jar <my-app>.jar
``` ```
- `<app_name>` is the name for your application - `<app_name>` is the name for your application
- `SIGNOZ_INGESTION_KEY` is the API token provided by SigNoz. You can find your ingestion key from SigNoz cloud account details sent on your email. - `SIGNOZ_INGESTION_KEY` is the API token provided by SigNoz. You can find your ingestion key from SigNoz cloud account details sent on your email.
Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table. Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
| Region | Endpoint | US - ingest.us.signoz.cloud:443 <br></br>
| ------ | -------------------------- |
| US | ingest.us.signoz.cloud:443 | IN - ingest.in.signoz.cloud:443 <br></br>
| IN | ingest.in.signoz.cloud:443 |
| EU | ingest.eu.signoz.cloud:443 | EU - ingest.eu.signoz.cloud:443 <br></br>
--- ---
@ -37,7 +52,6 @@ OTel Collector binary helps to collect logs, hostmetrics, resource and infra att
You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Java application. You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Java application.
Step 1. Download OTel java binary agent<br></br> Step 1. Download OTel java binary agent<br></br>
```bash ```bash
wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
``` ```
@ -50,9 +64,10 @@ java -javaagent:$PWD/opentelemetry-javaagent.jar -jar <myapp>.jar
- `<myapp>` is the name of your application jar file - `<myapp>` is the name of your application jar file
- In case you download `opentelemetry-javaagent.jar` file in different directory than that of the project, replace `$PWD` with the path of the otel jar file. - In case you download `opentelemetry-javaagent.jar` file in different directory than that of the project, replace `$PWD` with the path of the otel jar file.
---
</TabItem> ### Applications Deployed on Kubernetes
<TabItem value="k8s" label="Kubernetes">
For Java application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](/docs/tutorial/kubernetes-infra-metrics/). For Java application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](/docs/tutorial/kubernetes-infra-metrics/).
@ -65,7 +80,7 @@ Once you have set up OTel Collector agent, you can proceed with OpenTelemetry ja
``` ```
2. Run your application<br></br> 2. Run your application<br></br>
```bash ```bash
java -javaagent:$PWD/opentelemetry-javaagent.jar -jar <myapp>.jar java -javaagent:$PWD/opentelemetry-javaagent.jar -jar <myapp>.jar
``` ```
@ -73,9 +88,4 @@ Once you have set up OTel Collector agent, you can proceed with OpenTelemetry ja
- `<myapp>` is the name of your application jar file - `<myapp>` is the name of your application jar file
- In case you download `opentelemetry-javaagent.jar` file in different directory than that of the project, replace `$PWD` with the path of the otel jar file. - In case you download `opentelemetry-javaagent.jar` file in different directory than that of the project, replace `$PWD` with the path of the otel jar file.
3. Make sure to dockerise your application along with OpenTelemetry instrumentation. 3. Make sure to dockerise your application along with OpenTelemetry instrumentation.
You can validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces).
</TabItem>
</Tabs>

View File

@ -1,18 +1,23 @@
## Requirements
Java 8 or higher
## Send Traces to SigNoz Cloud ## Send Traces to SigNoz Cloud
OpenTelemetry provides a handy Java JAR agent that can be attached to any Java 8+ application and dynamically injects bytecode to capture telemetry from a number of popular libraries and frameworks. OpenTelemetry provides a handy Java JAR agent that can be attached to any Java 8+ application and dynamically injects bytecode to capture telemetry from a number of popular libraries and frameworks.
Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud. Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud.
### Application on VMs
From VMs, there are two ways to send data to SigNoz Cloud. From VMs, there are two ways to send data to SigNoz Cloud.
- [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud) - [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud)
- [Send traces via OTel Collector binary](#send-traces-via-otel-collector-binary) (recommended) - [Send traces via OTel Collector binary](#send-traces-via-otel-collector-binary) (recommended)
#### **Send traces directly to SigNoz Cloud** #### **Send traces directly to SigNoz Cloud**
OpenTelemetry Java agent can send traces directly to SigNoz Cloud. OpenTelemetry Java agent can send traces directly to SigNoz Cloud.
Step 1. Download otel java binary agent Step 1. Download otel java binary agent
```bash ```bash
@ -25,6 +30,7 @@ If you run your `.war` package by putting in `webapps` folder, just add `setenv.
This should set these environment variables and start sending telemetry data to SigNoz Cloud. This should set these environment variables and start sending telemetry data to SigNoz Cloud.
```bash ```bash
export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/opentelemetry-javaagent.jar" export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/opentelemetry-javaagent.jar"
export OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=SIGNOZ_INGESTION_KEY" export OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=SIGNOZ_INGESTION_KEY"
@ -37,11 +43,11 @@ export OTEL_RESOURCE_ATTRIBUTES=service.name=<app_name>
Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table. Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
| Region | Endpoint | US - ingest.us.signoz.cloud:443 <br></br>
| ------ | -------------------------- |
| US | ingest.us.signoz.cloud:443 | IN - ingest.in.signoz.cloud:443 <br></br>
| IN | ingest.in.signoz.cloud:443 |
| EU | ingest.eu.signoz.cloud:443 | EU - ingest.eu.signoz.cloud:443 <br></br>
--- ---
@ -52,7 +58,6 @@ OTel Collector binary helps to collect logs, hostmetrics, resource and infra att
You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Java application. You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Java application.
Step 1. Download OTel java binary agent<br></br> Step 1. Download OTel java binary agent<br></br>
```bash ```bash
wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
``` ```
@ -63,12 +68,17 @@ If you run your `.war` package by putting in `webapps` folder, just add `setenv.
This should set these environment variables and start sending telemetry data to SigNoz Cloud. This should set these environment variables and start sending telemetry data to SigNoz Cloud.
```bash ```bash
export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/opentelemetry-javaagent.jar" export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/opentelemetry-javaagent.jar"
``` ```
- path/to - Update it to the path of your downloaded Java JAR agent. - path/to - Update it to the path of your downloaded Java JAR agent.
---
### Applications Deployed on Kubernetes
For Java application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](/docs/tutorial/kubernetes-infra-metrics/). For Java application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](/docs/tutorial/kubernetes-infra-metrics/).
Once you have set up OTel Collector agent, you can proceed with OpenTelemetry java instrumentation by following the below steps: Once you have set up OTel Collector agent, you can proceed with OpenTelemetry java instrumentation by following the below steps:
@ -82,9 +92,9 @@ Once you have set up OTel Collector agent, you can proceed with OpenTelemetry ja
2. Enable the instrumentation agent and run your application<br></br> 2. Enable the instrumentation agent and run your application<br></br>
If you run your `.war` package by putting in `webapps` folder, just add `setenv.sh` in your Tomcat `bin` folder. If you run your `.war` package by putting in `webapps` folder, just add `setenv.sh` in your Tomcat `bin` folder.
This should set the environment variable and start sending telemetry data to SigNoz Cloud. This should set the environment variable and start sending telemetry data to SigNoz Cloud.
```bash ```bash
export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/opentelemetry-javaagent.jar" export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/opentelemetry-javaagent.jar"
``` ```
@ -93,4 +103,4 @@ Once you have set up OTel Collector agent, you can proceed with OpenTelemetry ja
3. Make sure to dockerise your application along with OpenTelemetry instrumentation. 3. Make sure to dockerise your application along with OpenTelemetry instrumentation.
You can validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces). You can validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces).

View File

@ -6,7 +6,6 @@ import Header from 'container/OnboardingContainer/common/Header/Header';
import { useState } from 'react'; import { useState } from 'react';
import ConnectionStatus from '../common/ConnectionStatus/ConnectionStatus'; import ConnectionStatus from '../common/ConnectionStatus/ConnectionStatus';
import AngularDocs from './md-docs/angular.md';
import ExpressDocs from './md-docs/express.md'; import ExpressDocs from './md-docs/express.md';
import JavascriptDocs from './md-docs/javascript.md'; import JavascriptDocs from './md-docs/javascript.md';
import NestJsDocs from './md-docs/nestjs.md'; import NestJsDocs from './md-docs/nestjs.md';
@ -14,8 +13,7 @@ import NestJsDocs from './md-docs/nestjs.md';
const frameworksMap = { const frameworksMap = {
express: 'Express', express: 'Express',
nestjs: 'Nest JS', nestjs: 'Nest JS',
angular: 'Angular', nodejs: 'Nodejs',
other: 'Others',
}; };
export default function Javascript({ export default function Javascript({
@ -23,20 +21,18 @@ export default function Javascript({
}: { }: {
activeStep: number; activeStep: number;
}): JSX.Element { }): JSX.Element {
const [selectedFrameWork, setSelectedFrameWork] = useState('express'); const [selectedFrameWork, setSelectedFrameWork] = useState('nodejs');
const [form] = Form.useForm(); const [form] = Form.useForm();
const renderDocs = (): JSX.Element => { const renderDocs = (): JSX.Element => {
switch (selectedFrameWork) { switch (selectedFrameWork) {
case 'express': case 'nodejs':
return <ExpressDocs />; return <JavascriptDocs />;
case 'nestjs': case 'nestjs':
return <NestJsDocs />; return <NestJsDocs />;
case 'angular':
return <AngularDocs />;
default: default:
return <JavascriptDocs />; return <ExpressDocs />;
} }
}; };
@ -62,6 +58,10 @@ export default function Javascript({
placeholder="Select Framework" placeholder="Select Framework"
onChange={(value): void => setSelectedFrameWork(value)} onChange={(value): void => setSelectedFrameWork(value)}
options={[ options={[
{
value: 'nodejs',
label: frameworksMap.nodejs,
},
{ {
value: 'express', value: 'express',
label: frameworksMap.express, label: frameworksMap.express,
@ -70,14 +70,6 @@ export default function Javascript({
value: 'nestjs', value: 'nestjs',
label: frameworksMap.nestjs, label: frameworksMap.nestjs,
}, },
{
value: 'angular',
label: frameworksMap.angular,
},
{
value: 'other',
label: frameworksMap.other,
},
]} ]}
/> />
</div> </div>

View File

@ -1,57 +0,0 @@
## Instrumenting your Angular App with OpenTelemetry 🛠
#### Pre-requisites
Enable CORS in the OTel Receiver. Inside `docker/clickhouse-setup/otel-collector-config.yaml` add the following CORS config. You can view the file at [SigNoz GitHub repo](https://github.com/SigNoz/signoz/blob/develop/deploy/docker/clickhouse-setup/otel-collector-config.yaml).
```yml
http:
+ cors:
+ allowed_origins:
+ - https://netflix.com # URL of your Frontend application
```
> Make sure to restart the container after making the config changes
Now let's get back to instrumenting our Angular Application. Let's start by installing a couple of dependencies.
```sh
npm i @jufab/opentelemetry-angular-interceptor && npm i @opentelemetry/api @opentelemetry/sdk-trace-web @opentelemetry/sdk-trace-base @opentelemetry/core @opentelemetry/semantic-conventions @opentelemetry/resources @opentelemetry/exporter-trace-otlp-http @opentelemetry/exporter-zipkin @opentelemetry/propagator-b3 @opentelemetry/propagator-jaeger @opentelemetry/context-zone-peer-dep @opentelemetry/instrumentation @opentelemetry/instrumentation-document-load @opentelemetry/instrumentation-fetch @opentelemetry/instrumentation-xml-http-request @opentelemetry/propagator-aws-xray --save-dev
```
Not let's import OTel module in `app.module.ts`
```ts
import {
OpenTelemetryInterceptorModule,
OtelColExporterModule,
CompositePropagatorModule,
} from '@jufab/opentelemetry-angular-interceptor';
@NgModule({
...
imports: [
...
OpenTelemetryInterceptorModule.forRoot({
commonConfig: {
console: true, // Display trace on console (only in DEV env)
production: false, // Send Trace with BatchSpanProcessor (true) or SimpleSpanProcessor (false)
serviceName: 'Angular Sample App', // Service name send in trace
probabilitySampler: '1',
},
otelcolConfig: {
url: 'http://127.0.0.1:4318/v1/traces', // URL of opentelemetry collector
},
}),
//Insert OtelCol exporter module
OtelColExporterModule,
//Insert propagator module
CompositePropagatorModule,
],
...
})
```
This config would be enough to get you up and running. For more tweaks refer to [this](https://github.com/jufab/opentelemetry-angular-interceptor#readme) detailed documentation of the instrumentation library.
Facing difficulties with instrumenting your application? Check out this video tutorial 👇

View File

@ -1,132 +1,213 @@
## Send Traces Directly to SigNoz ## Requirements
### Using the all-in-one auto-instrumentation library Supported Versions
The recommended way to instrument your Express application is to use the all-in-one auto-instrumentation library - `@opentelemetry/auto-instrumentations-node`. It provides a simple way to initialize multiple Nodejs instrumentations. ^4.0.0
Internally, it calls the specific auto-instrumentation library for components used in the application. You can see the complete list [here](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/metapackages/auto-instrumentations-node#supported-instrumentations). ## Send traces to SigNoz Cloud
#### Steps to auto-instrument Express application Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud.
1. Install the dependencies<br></br> ### Application on VMs
We start by installing the relevant dependencies.
```bash From VMs, there are two ways to send data to SigNoz Cloud.
npm install --save @opentelemetry/sdk-node
npm install --save @opentelemetry/auto-instrumentations-node
npm install --save @opentelemetry/exporter-trace-otlp-http
```
The dependencies included are briefly explained below:<br></br> - [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud)
- [Send traces via OTel Collector binary](#send-traces-via-otel-collector-binary) (recommended)
`@opentelemetry/sdk-node` - This package provides the full OpenTelemetry SDK for Node.js including tracing and metrics.<br></br> #### **Send traces directly to SigNoz Cloud**
`@opentelemetry/auto-instrumentations-node` - This module provides a simple way to initialize multiple Node instrumentations.<br></br> Step 1. Install OpenTelemetry packages
`@opentelemetry/exporter-trace-otlp-http` - This module provides the exporter to be used with OTLP (`http/json`) compatible receivers.<br></br> ```bash
npm install --save @opentelemetry/api@^1.4.1
npm install --save @opentelemetry/sdk-node@^0.39.1
npm install --save @opentelemetry/auto-instrumentations-node@^0.37.0
npm install --save @opentelemetry/exporter-trace-otlp-http@^0.39.1
```
<VersionPin /> Step 2. Create tracing.js file<br></br>
2. **Create a `tracing.js` file**<br></br> You need to configure the endpoint for SigNoz cloud in this file. You can find your ingestion key from SigNoz cloud account details sent on your email.
The `tracing.js` file will contain the tracing setup code. Notice, that we have set some environment variables in the code(highlighted). You can update these variables based on your environment.
````jsx ```js
// tracing.js // tracing.js
'use strict' 'use strict'
const process = require('process'); const process = require('process');
const opentelemetry = require('@opentelemetry/sdk-node'); const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node'); const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http'); const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { Resource } = require('@opentelemetry/resources'); const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions'); const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const exporterOptions = { // 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
// highlight-start
const exporterOptions = {
url: 'https://ingest.{region}.signoz.cloud:443/v1/traces'
}
// highlight-end
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
// highlight-next-line // highlight-next-line
url: 'http://localhost:4318/v1/traces' [SemanticResourceAttributes.SERVICE_NAME]: 'node_app'
} })
});
const traceExporter = new OTLPTraceExporter(exporterOptions); // initialize the SDK and register with the OpenTelemetry API
const sdk = new opentelemetry.NodeSDK({ // this enables the API to record telemetry
traceExporter, sdk.start()
instrumentations: [getNodeAutoInstrumentations()],
// highlight-start
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'node_app'
})
// highlight-end
});
// initialize the SDK and register with the OpenTelemetry API // gracefully shut down the SDK on process exit
// this enables the API to record telemetry process.on('SIGTERM', () => {
sdk.start() sdk.shutdown()
.then(() => console.log('Tracing terminated'))
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});
```
// gracefully shut down the SDK on process exit Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
process.on('SIGTERM', () => {
sdk.shutdown()
.then(() => console.log('Tracing terminated'))
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});
```
OpenTelemetry Node SDK currently does not detect the `OTEL_RESOURCE_ATTRIBUTES` from `.env` files as of today. Thats why we need to include the variables in the `tracing.js` file itself. US - ingest.us.signoz.cloud:443/v1/traces <br></br>
About environment variables: IN - ingest.in.signoz.cloud:443/v1/traces <br></br>
`service_name` : node_app (you can give whatever name that suits you) EU - ingest.eu.signoz.cloud:443/v1/traces <br></br>
`http://localhost:4318/v1/traces` is the default url for sending your tracing data. We are assuming you have installed SigNoz on your `localhost`. Based on your environment, you can update it accordingly. It should be in the following format: Step 3. Run the application<br></br>
`http://<IP of SigNoz backend>:4318/v1/traces` Make sure you set the `OTEL_EXPORTER_OTLP_HEADERS` env as follows
```bash
OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=<SIGNOZ_INGESTION_KEY>" node -r ./tracing.js app.js
```
Heres a handy [grid](https://signoz.io/docs/instrumentation/troubleshoot-instrumentation/) to figure out which address to use to send data to SigNoz. `SIGNOZ_INGESTION_KEY` is the API token provided by SigNoz. You can find your ingestion key from SigNoz cloud account details sent on your email.
:::note ---
Remember to allow incoming requests to port 4318 of machine where SigNoz backend is hosted.
#### **Send traces via OTel Collector binary**
OTel Collector binary helps to collect logs, hostmetrics, resource and infra attributes. It is recommended to install Otel Collector binary to collect and send traces to SigNoz cloud. You can correlate signals and have rich contextual data through this way.
You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Javascript application.
Step 1. Install OpenTelemetry packages
3. **Run the application**<br></br> ```js
The tracing configuration should be run before your application code. We will use the [`-r, —require module`](https://nodejs.org/api/cli.html#cli_r_require_module) flag for that.<br></br> npm install --save @opentelemetry/api@^1.4.1
npm install --save @opentelemetry/sdk-node@^0.39.1
npm install --save @opentelemetry/auto-instrumentations-node@^0.37.0
npm install --save @opentelemetry/exporter-trace-otlp-http@^0.39.1
```
```jsx Step 2. Create tracing.js file<br></br>
node -r ./tracing.js app.js
```
:::note ```js
If you're running your nodejs application in PM2 cluster mode, it doesn't support node args: [Unitech/pm2#3227](https://github.com/Unitech/pm2/issues/3227). As above sample app instrumentation requires to load `tracing.js` before app load by passing node arg, so nodejs instrumentation doesn't work in PM2 cluster mode. So you need to import `tracing.js` in your main application. The `import ./tracing.js` should be the first line of your application code and initialize it before any other function. Here's the [sample github repo](https://github.com/SigNoz/sample-nodejs-app/tree/init-tracer-main) which shows the implementation. // 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');
### Validating instrumentation by checking for traces const exporterOptions = {
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces',
}
With your application running, you can verify that youve instrumented your application with OpenTelemetry correctly by confirming that tracing data is being reported to SigNoz. const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
// highlight-next-line
[SemanticResourceAttributes.SERVICE_NAME]: 'node_app'
})
});
To do this, you need to ensure that your application generates some data. Applications will not produce traces unless they are being interacted with, and OpenTelemetry will often buffer data before sending. So you need to interact with your application and wait for some time to see your tracing data in SigNoz. // initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start()
Validate your traces in SigNoz: // 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));
});
```
1. Trigger an action in your app that generates a web request. Hit the endpoint a number of times to generate some data. Then, wait for some time. Step 3. Run the application<br></br>
2. In SigNoz, open the `Services` tab. Hit the `Refresh` button on the top right corner, and your application should appear in the list of `Applications`. ```bash
3. Go to the `Traces` tab, and apply relevant filters to see your applications traces. node -r ./tracing.js app.js
```
---
You might see other dummy applications if youre using SigNoz for the first time. You can remove it by following the docs [here](https://signoz.io/docs/operate/docker-standalone/#remove-the-sample-application). ### Applications Deployed on Kubernetes
<figure data-zoomable align='center'> For Javascript application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](/docs/tutorial/kubernetes-infra-metrics/).
<img src="/img/docs/express_application_services_list.webp" alt="Nestjs Application in the list of services being monitored in SigNoz"/>
<figcaption><i>Express Application in the list of services being monitored in SigNoz</i></figcaption>
</figure>
<br></br> Once you have set up OTel Collector agent, you can proceed with OpenTelemetry Javascript instrumentation by following the below steps:
If you don't see your application reported in the list of services, try our [troubleshooting](https://signoz.io/docs/install/troubleshooting/) guide. Step 1. Install OpenTelemetry packages
```bash
npm install --save @opentelemetry/api@^1.4.1
npm install --save @opentelemetry/sdk-node@^0.39.1
npm install --save @opentelemetry/auto-instrumentations-node@^0.37.0
npm install --save @opentelemetry/exporter-trace-otlp-http@^0.39.1
```
### Using a specific auto-instrumentation library Step 2. Create tracing.js file<br></br>
If you want to instrument only your Express framework, then you need to use the following package: ```js
// 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');
```jsx const exporterOptions = {
npm install --save @opentelemetry/instrumentation-express url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces',
```` }
Note that in the above case, you will have to install packages for all the components that you want to instrument with OpenTelemetry individually. You can find detailed instructions [here](https://signoz.io/docs/instrumentation/javascript/#using-a-specific-auto-instrumentation-library). const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
// highlight-next-line
[SemanticResourceAttributes.SERVICE_NAME]: 'node_app'
})
});
// 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. Run the application<br></br>
```bash
node -r ./tracing.js app.js
```

View File

@ -1,7 +1,13 @@
## Requirements
- Node.js version 14 or newer ([See here](https://github.com/open-telemetry/opentelemetry-js#supported-runtimes))<br></br>
## Send traces to SigNoz Cloud ## Send traces to SigNoz Cloud
Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud. Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud.
### Application on VMs
From VMs, there are two ways to send data to SigNoz Cloud. From VMs, there are two ways to send data to SigNoz Cloud.
- [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud) - [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud)
@ -11,74 +17,69 @@ From VMs, there are two ways to send data to SigNoz Cloud.
Step 1. Install OpenTelemetry packages Step 1. Install OpenTelemetry packages
```js ```bash
npm install --save @opentelemetry/api@^1.4.1 npm install --save @opentelemetry/api@^1.4.1
npm install --save @opentelemetry/sdk-node@^0.39.1 npm install --save @opentelemetry/sdk-node@^0.39.1
npm install --save @opentelemetry/auto-instrumentations-node@^0.37.0 npm install --save @opentelemetry/auto-instrumentations-node@^0.37.0
npm install --save @opentelemetry/exporter-trace-otlp-grpc@^0.39.1 npm install --save @opentelemetry/exporter-trace-otlp-http@^0.39.1
``` ```
Step 2. Create tracing.js file<br></br> Step 2. Create tracing.js file<br></br>
You need to configure the endpoint for SigNoz cloud in this file. You can find your ingestion key from SigNoz cloud account details sent on your email. You need to configure the endpoint for SigNoz cloud in this file. You can find your ingestion key from SigNoz cloud account details sent on your email.
```js ```js
// tracing.js // tracing.js
'use strict'; 'use strict'
const process = require('process'); const process = require('process');
const opentelemetry = require('@opentelemetry/sdk-node'); const opentelemetry = require('@opentelemetry/sdk-node');
const { const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
getNodeAutoInstrumentations, const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
} = require('@opentelemetry/auto-instrumentations-node');
const {
OTLPTraceExporter,
} = require('@opentelemetry/exporter-trace-otlp-grpc');
const { Resource } = require('@opentelemetry/resources'); const { Resource } = require('@opentelemetry/resources');
const { const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
SemanticResourceAttributes,
} = require('@opentelemetry/semantic-conventions');
// do not set headers in exporterOptions, the OTel spec recommends setting headers through ENV variables // 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 // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#specifying-headers-via-environment-variables
// highlight-start // highlight-start
const exporterOptions = { const exporterOptions = {
url: 'https://ingest.{region}.signoz.cloud:443', url: 'https://ingest.{region}.signoz.cloud:443/v1/traces'
}; }
// highlight-end // highlight-end
const traceExporter = new OTLPTraceExporter(exporterOptions); const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({ const sdk = new opentelemetry.NodeSDK({
traceExporter, traceExporter,
instrumentations: [getNodeAutoInstrumentations()], instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({ resource: new Resource({
// highlight-next-line // highlight-next-line
[SemanticResourceAttributes.SERVICE_NAME]: 'node_app', [SemanticResourceAttributes.SERVICE_NAME]: 'node_app'
}), })
}); });
// initialize the SDK and register with the OpenTelemetry API // initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry // this enables the API to record telemetry
sdk.start(); sdk.start()
// gracefully shut down the SDK on process exit // gracefully shut down the SDK on process exit
process.on('SIGTERM', () => { process.on('SIGTERM', () => {
sdk sdk.shutdown()
.shutdown() .then(() => console.log('Tracing terminated'))
.then(() => console.log('Tracing terminated')) .catch((error) => console.log('Error terminating tracing', error))
.catch((error) => console.log('Error terminating tracing', error)) .finally(() => process.exit(0));
.finally(() => process.exit(0));
}); });
``` ```
Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table. Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
| Region | Endpoint | US - ingest.us.signoz.cloud:443/v1/traces <br></br>
| ------ | -------------------------- |
| US | ingest.us.signoz.cloud:443 | IN - ingest.in.signoz.cloud:443/v1/traces <br></br>
| IN | ingest.in.signoz.cloud:443 |
| EU | ingest.eu.signoz.cloud:443 | EU - ingest.eu.signoz.cloud:443/v1/traces <br></br>
Step 3. Run the application<br></br> Step 3. Run the application<br></br>
Make sure you set the `OTEL_EXPORTER_OTLP_HEADERS` env as follows Make sure you set the `OTEL_EXPORTER_OTLP_HEADERS` env as follows
```bash ```bash
@ -87,15 +88,13 @@ OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=<SIGNOZ_INGESTION_KEY>" node -r
`SIGNOZ_INGESTION_KEY` is the API token provided by SigNoz. You can find your ingestion key from SigNoz cloud account details sent on your email. `SIGNOZ_INGESTION_KEY` is the API token provided by SigNoz. You can find your ingestion key from SigNoz cloud account details sent on your email.
Step 4. You can validate if your application is sending traces to SigNoz cloud [here](#validating-instrumentation-by-checking-for-traces). ---
#### **Send traces via OTel Collector binary** #### **Send traces via OTel Collector binary**
OTel Collector binary helps to collect logs, hostmetrics, resource and infra attributes. It is recommended to install Otel Collector binary to collect and send traces to SigNoz cloud. You can correlate signals and have rich contextual data through this way. OTel Collector binary helps to collect logs, hostmetrics, resource and infra attributes. It is recommended to install Otel Collector binary to collect and send traces to SigNoz cloud. You can correlate signals and have rich contextual data through this way.
:::note
You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Javascript application. You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Javascript application.
:::
Step 1. Install OpenTelemetry packages Step 1. Install OpenTelemetry packages
@ -103,52 +102,45 @@ Step 1. Install OpenTelemetry packages
npm install --save @opentelemetry/api@^1.4.1 npm install --save @opentelemetry/api@^1.4.1
npm install --save @opentelemetry/sdk-node@^0.39.1 npm install --save @opentelemetry/sdk-node@^0.39.1
npm install --save @opentelemetry/auto-instrumentations-node@^0.37.0 npm install --save @opentelemetry/auto-instrumentations-node@^0.37.0
npm install --save @opentelemetry/exporter-trace-otlp-grpc@^0.39.1 npm install --save @opentelemetry/exporter-trace-otlp-http@^0.39.1
``` ```
Step 2. Create tracing.js file<br></br> Step 2. Create tracing.js file<br></br>
```js ```js
// tracing.js // tracing.js
'use strict'; 'use strict'
const process = require('process'); const process = require('process');
const opentelemetry = require('@opentelemetry/sdk-node'); const opentelemetry = require('@opentelemetry/sdk-node');
const { const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
getNodeAutoInstrumentations, const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
} = require('@opentelemetry/auto-instrumentations-node');
const {
OTLPTraceExporter,
} = require('@opentelemetry/exporter-trace-otlp-grpc');
const { Resource } = require('@opentelemetry/resources'); const { Resource } = require('@opentelemetry/resources');
const { const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
SemanticResourceAttributes,
} = require('@opentelemetry/semantic-conventions');
const exporterOptions = { const exporterOptions = {
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4317', url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces',
}; }
const traceExporter = new OTLPTraceExporter(exporterOptions); const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({ const sdk = new opentelemetry.NodeSDK({
traceExporter, traceExporter,
instrumentations: [getNodeAutoInstrumentations()], instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({ resource: new Resource({
// highlight-next-line // highlight-next-line
[SemanticResourceAttributes.SERVICE_NAME]: 'node_app', [SemanticResourceAttributes.SERVICE_NAME]: 'node_app'
}), })
}); });
// initialize the SDK and register with the OpenTelemetry API // initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry // this enables the API to record telemetry
sdk.start(); sdk.start()
// gracefully shut down the SDK on process exit // gracefully shut down the SDK on process exit
process.on('SIGTERM', () => { process.on('SIGTERM', () => {
sdk sdk.shutdown()
.shutdown() .then(() => console.log('Tracing terminated'))
.then(() => console.log('Tracing terminated')) .catch((error) => console.log('Error terminating tracing', error))
.catch((error) => console.log('Error terminating tracing', error)) .finally(() => process.exit(0));
.finally(() => process.exit(0));
}); });
``` ```
@ -158,10 +150,9 @@ Step 3. Run the application<br></br>
node -r ./tracing.js app.js node -r ./tracing.js app.js
``` ```
Step 4. You can validate if your application is sending traces to SigNoz cloud [here](#validating-instrumentation-by-checking-for-traces). ---
</TabItem> ### Applications Deployed on Kubernetes
<TabItem value="k8s" label="Kubernetes">
For Javascript application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](/docs/tutorial/kubernetes-infra-metrics/). For Javascript application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](/docs/tutorial/kubernetes-infra-metrics/).
@ -173,59 +164,49 @@ Step 1. Install OpenTelemetry packages
npm install --save @opentelemetry/api@^1.4.1 npm install --save @opentelemetry/api@^1.4.1
npm install --save @opentelemetry/sdk-node@^0.39.1 npm install --save @opentelemetry/sdk-node@^0.39.1
npm install --save @opentelemetry/auto-instrumentations-node@^0.37.0 npm install --save @opentelemetry/auto-instrumentations-node@^0.37.0
npm install --save @opentelemetry/exporter-trace-otlp-grpc@^0.39.1 npm install --save @opentelemetry/exporter-trace-otlp-http@^0.39.1
``` ```
Step 2. Create tracing.js file<br></br> Step 2. Create tracing.js file<br></br>
```js ```js
// tracing.js // tracing.js
'use strict'; 'use strict'
const process = require('process'); const process = require('process');
const opentelemetry = require('@opentelemetry/sdk-node'); const opentelemetry = require('@opentelemetry/sdk-node');
const { const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
getNodeAutoInstrumentations, const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
} = require('@opentelemetry/auto-instrumentations-node');
const {
OTLPTraceExporter,
} = require('@opentelemetry/exporter-trace-otlp-grpc');
const { Resource } = require('@opentelemetry/resources'); const { Resource } = require('@opentelemetry/resources');
const { const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
SemanticResourceAttributes,
} = require('@opentelemetry/semantic-conventions');
const exporterOptions = { const exporterOptions = {
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4317', url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces',
}; }
const traceExporter = new OTLPTraceExporter(exporterOptions); const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({ const sdk = new opentelemetry.NodeSDK({
traceExporter, traceExporter,
instrumentations: [getNodeAutoInstrumentations()], instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({ resource: new Resource({
// highlight-next-line // highlight-next-line
[SemanticResourceAttributes.SERVICE_NAME]: 'node_app', [SemanticResourceAttributes.SERVICE_NAME]: 'node_app'
}), })
}); });
// initialize the SDK and register with the OpenTelemetry API // initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry // this enables the API to record telemetry
sdk.start(); sdk.start()
// gracefully shut down the SDK on process exit // gracefully shut down the SDK on process exit
process.on('SIGTERM', () => { process.on('SIGTERM', () => {
sdk sdk.shutdown()
.shutdown() .then(() => console.log('Tracing terminated'))
.then(() => console.log('Tracing terminated')) .catch((error) => console.log('Error terminating tracing', error))
.catch((error) => console.log('Error terminating tracing', error)) .finally(() => process.exit(0));
.finally(() => process.exit(0));
}); });
``` ```
Step 3. Run the application<br></br> Step 3. Run the application<br></br>
```bash ```bash
node -r ./tracing.js app.js node -r ./tracing.js app.js
``` ```
Step 4. You can validate if your application is sending traces to SigNoz cloud [here](#validating-instrumentation-by-checking-for-traces).

View File

@ -1,129 +1,300 @@
## Send Traces Directly to SigNoz ## Requirements
### Using the all-in-one auto-instrumentation library **Supported Versions**
The recommended way to instrument your Nestjs application is to use the all-in-one auto-instrumentation library - `@opentelemetry/auto-instrumentations-node`. It provides a simple way to initialize multiple Nodejs instrumentations. - `>=4.0.0`
Internally, it calls the specific auto-instrumentation library for components used in the application. You can see the complete list [here](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/metapackages/auto-instrumentations-node#supported-instrumentations). ## Send traces to SigNoz Cloud
#### Steps to auto-instrument Nestjs application Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud.
1. Install the dependencies<br></br> ### Application on VMs
We start by installing the relevant dependencies.
```bash From VMs, there are two ways to send data to SigNoz Cloud.
npm install --save @opentelemetry/sdk-node
npm install --save @opentelemetry/auto-instrumentations-node
npm install --save @opentelemetry/exporter-trace-otlp-http
```
<NestjsPinnedVersions /> - [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud)
- [Send traces via OTel Collector binary](#send-traces-via-otel-collector-binary) (recommended)
2. Create a `tracer.ts` file #### **Send traces directly to SigNoz Cloud**
```jsx Step 1. Install OpenTelemetry packages
'use strict';
const process = require('process');
//OpenTelemetry
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 = { ```bash
url: 'http://localhost:4318/v1/traces', npm install --save @opentelemetry/api@^1.4.1
}; npm install --save @opentelemetry/sdk-node@^0.39.1
npm install --save @opentelemetry/auto-instrumentations-node@^0.37.0
const traceExporter = new OTLPTraceExporter(exporterOptions); npm install --save @opentelemetry/exporter-trace-otlp-http@^0.39.1
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'sampleNestjsApplication',
}),
});
// 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));
});
module.exports = sdk;
```
3. Import the tracer module where your app starts
```jsx
const tracer = require('./tracer');
```
4. Start the tracer<br></br>
In the `async function boostrap` section of the application code, initialize the tracer as follows:
```jsx
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() {
// highlight-start
await tracer.start();
//highlight-end
const app = await NestFactory.create(AppModule);
await app.listen(3001);
}
bootstrap();
```
You can now run your Nestjs application. The data captured with OpenTelemetry from your application should start showing on the SigNoz dashboard.
### Validating instrumentation by checking for traces
With your application running, you can verify that youve instrumented your application with OpenTelemetry correctly by confirming that tracing data is being reported to SigNoz.
To do this, you need to ensure that your application generates some data. Applications will not produce traces unless they are being interacted with, and OpenTelemetry will often buffer data before sending. So you need to interact with your application and wait for some time to see your tracing data in SigNoz.
Validate your traces in SigNoz:
1. Trigger an action in your app that generates a web request. Hit the endpoint a number of times to generate some data. Then, wait for some time.
2. In SigNoz, open the `Services` tab. Hit the `Refresh` button on the top right corner, and your application should appear in the list of `Applications`.
3. Go to the `Traces` tab, and apply relevant filters to see your applications traces.
You might see other dummy applications if youre using SigNoz for the first time. You can remove it by following the docs [here](https://signoz.io/docs/operate/docker-standalone/#remove-the-sample-application).
<figure data-zoomable align='center'>
<img src="/img/docs/nestjs_application_instrumented.webp" alt="Nestjs Application in the list of services being monitored in SigNoz"/>
<figcaption><i>Nestjs Application in the list of services being monitored in SigNoz</i></figcaption>
</figure>
<br></br>
If you don't see your application reported in the list of services, try our [troubleshooting](https://signoz.io/docs/install/troubleshooting/) guide.
### Using a specific auto-instrumentation library
If you want to instrument only your Nestjs framework, then you need to use the following package:
```jsx
npm install --save @opentelemetry/instrumentation-nestjs-core
``` ```
Note that in the above case, you will have to install packages for all the components that you want to instrument with OpenTelemetry individually. You can find detailed instructions [here](https://signoz.io/docs/instrumentation/javascript/#using-a-specific-auto-instrumentation-library). Step 2. Create `tracer.ts` file<br></br>
You need to configure the endpoint for SigNoz cloud in this file.
```js
'use strict'
const process = require('process');
//OpenTelemetry
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 = {
// highlight-start
url: 'https://ingest.{region}.signoz.cloud:443/v1/traces'
// highlight-end
}
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'sampleNestjsApplication'
})
});
// 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));
});
module.exports = sdk
```
Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
US - ingest.us.signoz.cloud:443/v1/traces <br></br>
IN - ingest.in.signoz.cloud:443/v1/traces <br></br>
EU - ingest.eu.signoz.cloud:443/v1/traces <br></br>
Step 3. Import the tracer module where your app starts
```jsx
const tracer = require('./tracer')
```
Step 4. Start the tracer<br></br>
In the `async function boostrap` section of the application code, initialize the tracer as follows:
```jsx
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() {
// highlight-start
await tracer.start();
//highlight-end
const app = await NestFactory.create(AppModule);
await app.listen(3001);
}
bootstrap();
```
Step 5. Run the application
```bash
OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=<SIGNOZ_INGESTION_KEY>" nest start
```
You can now run your Nestjs application. The data captured with OpenTelemetry from your application should start showing on the SigNoz dashboard.
`SIGNOZ_INGESTION_KEY` is the API token provided by SigNoz. You can find your ingestion key from SigNoz cloud account details sent on your email.
---
#### **Send traces via OTel Collector binary**
OTel Collector binary helps to collect logs, hostmetrics, resource and infra attributes. It is recommended to install Otel Collector binary to collect and send traces to SigNoz cloud. You can correlate signals and have rich contextual data through this way.
You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Javascript application.
Step 1. Install OpenTelemetry packages
```js
npm install --save @opentelemetry/api@^1.4.1
npm install --save @opentelemetry/sdk-node@^0.39.1
npm install --save @opentelemetry/auto-instrumentations-node@^0.37.0
npm install --save @opentelemetry/exporter-trace-otlp-http@^0.39.1
```
Step 2. Create `tracer.ts` file<br></br>
```js
'use strict'
const process = require('process');
//OpenTelemetry
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 = {
// highlight-start
url: 'http://localhost:4318/v1/traces'
// highlight-end
}
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'sampleNestjsApplication'
})
});
// 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));
});
module.exports = sdk
```
Step 3. Import the tracer module where your app starts
```jsx
const tracer = require('./tracer')
```
Step 4. Start the tracer<br></br>
In the `async function boostrap` section of the application code, initialize the tracer as follows:
```jsx
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() {
// highlight-start
await tracer.start();
//highlight-end
const app = await NestFactory.create(AppModule);
await app.listen(3001);
}
bootstrap();
```
Step 5. Run the application
---
### Applications Deployed on Kubernetes
For Javascript application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](/docs/tutorial/kubernetes-infra-metrics/).
Once you have set up OTel Collector agent, you can proceed with OpenTelemetry Javascript instrumentation by following the below steps:
Step 1. Install OpenTelemetry packages
```bash
npm install --save @opentelemetry/api@^1.4.1
npm install --save @opentelemetry/sdk-node@^0.39.1
npm install --save @opentelemetry/auto-instrumentations-node@^0.37.0
npm install --save @opentelemetry/exporter-trace-otlp-http@^0.39.1
```
Step 2. Create `tracer.ts` file<br></br>
```js
'use strict'
const process = require('process');
//OpenTelemetry
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 = {
// highlight-start
url: 'http://localhost:4318/v1/traces'
// highlight-end
}
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'sampleNestjsApplication'
})
});
// 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));
});
module.exports = sdk
```
Step 3. Import the tracer module where your app starts
```jsx
const tracer = require('./tracer')
```
Step 4. Start the tracer<br></br>
In the `async function boostrap` section of the application code, initialize the tracer as follows:
```jsx
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() {
// highlight-start
await tracer.start();
//highlight-end
const app = await NestFactory.create(AppModule);
await app.listen(3001);
}
bootstrap();
```
Step 5. Run the application

View File

@ -1,92 +1,186 @@
## Send Traces Directly to SigNoz ## Requirements
You can use OpenTelemetry to send your traces directly to SigNoz. OpenTelemetry provides a handy distro in Python that can help you get started with automatic instrumentation. We recommend using it to get started quickly. - Python 3.8 or newer
### Steps to auto-instrument Django app for traces - for Django, you must define `DJANGO_SETTINGS_MODULE`correctly. If your project is called `mysite`, something like following should work:
1. **Create a virtual environment**<br></br>
```bash ```bash
python3 -m venv .venv export DJANGO_SETTINGS_MODULE=mysite.settings
source .venv/bin/activate
``` ```
2. **Install the OpenTelemetry dependencies**<br></br> Please refer the official [Django docs](https://docs.djangoproject.com/en/1.10/topics/settings/#designating-the-settings) for more details.
```bash
pip install opentelemetry-distro
pip install opentelemetry-exporter-otlp
```
The dependencies included are briefly explained below: ## Send Traces to SigNoz Cloud
`opentelemetry-distro` - The distro provides a mechanism to automatically configure some of the more common options for users. It helps to get started with OpenTelemetry auto-instrumentation quickly. Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud.
`opentelemetry-exporter-otlp` - This library provides a way to install all OTLP exporters. You will need an exporter to send the data to SigNoz. ### Application on VMs
:::note From VMs, there are two ways to send data to SigNoz Cloud.
💡 The `opentelemetry-exporter-otlp` is a convenient wrapper package to install all OTLP exporters. Currently, it installs:
- opentelemetry-exporter-otlp-proto-http - [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud)
- opentelemetry-exporter-otlp-proto-grpc - [Send traces via OTel Collector binary](#send-traces-via-otel-collector-binary) (recommended)
- (soon) opentelemetry-exporter-otlp-json-http #### **Send traces directly to SigNoz Cloud**
The `opentelemetry-exporter-otlp-proto-grpc` package installs the gRPC exporter which depends on the `grpcio` package. The installation of `grpcio` may fail on some platforms for various reasons. If you run into such issues, or you don't want to use gRPC, you can install the HTTP exporter instead by installing the `opentelemetry-exporter-otlp-proto-http` package. You need to set the `OTEL_EXPORTER_OTLP_PROTOCOL` environment variable to `http/protobuf` to use the HTTP exporter. Step 1. Create a virtual environment<br></br>
:::
```bash
python3 -m venv .venv
source .venv/bin/activate
```
3. **Add automatic instrumentation**<br></br> Step 2. Install the OpenTelemetry dependencies
The below command inspects the dependencies of your application and installs the instrumentation packages relevant for your Django application.
```bash ```bash
opentelemetry-bootstrap --action=install pip install opentelemetry-distro==0.38b0
``` pip install opentelemetry-exporter-otlp==1.17.0
```
:::note <!-- The dependencies included are briefly explained below:
Please make sure that you have installed all the dependencies of your application before running the above command. The command will not install instrumentation for the dependencies which are not installed.
:::
4. **Run your application**<br></br> `opentelemetry-distro` - The distro provides a mechanism to automatically configure some of the more common options for users. It helps to get started with OpenTelemetry auto-instrumentation quickly.
In the final run command, you can configure environment variables and flags. Flags for exporters:<br></br>
For running your application, there are a few things that you need to keep in mind. Below are the notes: `opentelemetry-exporter-otlp` - This library provides a way to install all OTLP exporters. You will need an exporter to send the data to SigNoz.
:::note
Dont run app in reloader/hot-reload mode as it breaks instrumentation. For example, you can disable the auto reload with `--noreload`.
:::
For running applications with application servers which are based on [pre fork model](#running-applications-with-gunicorn-uwsgi), like Gunicorn, uWSGI you have to add a post_fork hook or a @postfork decorator in your configuration. :::note
💡 The `opentelemetry-exporter-otlp` is a convenience wrapper package to install all OTLP exporters. Currently, it installs:
To start sending data to SigNoz, use the following run command: - opentelemetry-exporter-otlp-proto-http
- opentelemetry-exporter-otlp-proto-grpc
```bash - (soon) opentelemetry-exporter-otlp-json-http
OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> OTEL_EXPORTER_OTLP_ENDPOINT="http://<IP of SigNoz Backend>:4317" OTEL_EXPORTER_OTLP_PROTOCOL=grpc opentelemetry-instrument <your run command>
```
*<service_name>* is the name of service you want The `opentelemetry-exporter-otlp-proto-grpc` package installs the gRPC exporter which depends on the `grpcio` package. The installation of `grpcio` may fail on some platforms for various reasons. If you run into such issues, or you don't want to use gRPC, you can install the HTTP exporter instead by installing the `opentelemetry-exporter-otlp-proto-http` package. You need to set the `OTEL_EXPORTER_OTLP_PROTOCOL` environment variable to `http/protobuf` to use the HTTP exporter.
::: -->
*<your_run_command>* can be `python3 app.py` or `python manage.py runserver --noreload` Step 3. Add automatic instrumentation
`IP of SigNoz backend` is the IP of the machine where you installed SigNoz. If you have installed SigNoz on `localhost`, the endpoint will be `http://localhost:4317` for gRPC exporter and `http://localhost:4318` for HTTP exporter. ```bash
opentelemetry-bootstrap --action=install
```
:::note Please make sure that you have installed all the dependencies of your application before running the above command. The command will not install instrumentation for the dependencies which are not installed.
The port numbers are 4317 and 4318 for the gRPC and HTTP exporters respectively. Remember to allow incoming requests to port **4317**/**4318** of machine where SigNoz backend is hosted.
:::
### Validating instrumentation by checking for traces Step 4. Run your application
With your application running, you can verify that youve instrumented your application with OpenTelemetry correctly by confirming that tracing data is being reported to SigNoz. ```bash
OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.{region}.signoz.cloud:443" \
OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=SIGNOZ_INGESTION_KEY" \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc \
opentelemetry-instrument <your_run_command>
```
To do this, you need to ensure that your application generates some data. Applications will not produce traces unless they are being interacted with, and OpenTelemetry will often buffer data before sending. So you need to interact with your application and wait for some time to see your tracing data in SigNoz. - `<service_name>` is the name of the service you want
- <your_run_command> can be `python3 app.py` or `python manage.py runserver --noreload`
- Replace `SIGNOZ_INGESTION_KEY` with the api token provided by SigNoz. You can find it in the email sent by SigNoz with your cloud account details.
Validate your traces in SigNoz: Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
1. Trigger an action in your app that generates a web request. Hit the endpoint a number of times to generate some data. Then, wait for some time. US - ingest.us.signoz.cloud:443 <br></br>
2. In SigNoz, open the `Services` tab. Hit the `Refresh` button on the top right corner, and your application should appear in the list of `Applications`.
3. Go to the `Traces` tab, and apply relevant filters to see your applications traces.
You might see other dummy applications if youre using SigNoz for the first time. You can remove it by following the docs [here](https://signoz.io/docs/operate/docker-standalone/#remove-the-sample-application). IN - ingest.in.signoz.cloud:443 <br></br>
EU - ingest.eu.signoz.cloud:443 <br></br>
Note:
Dont run app in reloader/hot-reload mode as it breaks instrumentation. For example, you can disable the auto reload with `--noreload`.
---
#### **Send traces via OTel Collector binary**
OTel Collector binary helps to collect logs, hostmetrics, resource and infra attributes. It is recommended to install Otel Collector binary to collect and send traces to SigNoz cloud. You can correlate signals and have rich contextual data through this way.
You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Python application.
Step 1. Create a virtual environment<br></br>
```bash
python3 -m venv .venv
source .venv/bin/activate
```
Step 2. Install the OpenTelemetry dependencies
```bash
pip install opentelemetry-distro==0.38b0
pip install opentelemetry-exporter-otlp==1.17.0
```
Step 3. Add automatic instrumentation
```bash
opentelemetry-bootstrap --action=install
```
Step 4. To run your application and send data to collector in same VM:
```bash
OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317" \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc opentelemetry-instrument <your run command>
```
- <service_name> is the name of service you want
- <your_run_command>* can be `python3 app.py` or `python manage.py runserver --noreload`
- `http://localhost:4317` for gRPC exporter and `http://localhost:4318` for HTTP exporter.
In case you have OtelCollector Agent in different VM, replace localhost:4317 with `<IP Address of the VM>:4317`.
---
### Applications Deployed on Kubernetes
For Python application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](https://signoz.io/docs/tutorial/kubernetes-infra-metrics/).
Once you have set up OTel Collector agent, you can proceed with OpenTelemetry Python instrumentation by following the below steps:
Step 1. Create a virtual environment<br></br>
```bash
python3 -m venv .venv
source .venv/bin/activate
```
Step 2. Install the OpenTelemetry dependencies
```bash
pip install opentelemetry-distro==0.38b0
pip install opentelemetry-exporter-otlp==1.17.0
```
Step 3. Add automatic instrumentation
```bash
opentelemetry-bootstrap --action=install
```
Step 4. Run your application:
```bash
OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317" \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc opentelemetry-instrument <your run command>
```
<service_name> is the name of service you want
<your_run_command> can be `python3 app.py` or `python manage.py runserver --noreload`
`http://localhost:4317` for gRPC exporter and `http://localhost:4318` for HTTP exporter.
Note:
The port numbers are 4317 and 4318 for the gRPC and HTTP exporters respectively.
In case you have OtelCollector Agent in different VM, replace localhost:4317 with `<IP Address of the VM>:4317`.
Step 5. Make sure to dockerise your application along with OpenTelemetry instrumentation.
<figure data-zoomable align='center'>
<img src="/img/docs/opentelemetry_python_app_instrumented.webp" alt="Python Application in the list of services being monitored in SigNoz"/>
<figcaption><i>Python Application in the list of services being monitored in SigNoz</i></figcaption></figure>
<br></br>

View File

@ -1,92 +1,185 @@
## Send Traces Directly to SigNoz ## Requirements
You can use OpenTelemetry to send your traces directly to SigNoz. OpenTelemetry provides a handy distro in Python that can help you get started with automatic instrumentation. We recommend using it to get started quickly. - Python 3.8 or newer
### Steps to auto-instrument Falcon app for traces ## Send Traces to SigNoz Cloud
1. **Create a virtual environment**<br></br> Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud.
```bash ### Application on VMs
python3 -m venv .venv
source .venv/bin/activate
```
2. **Install the OpenTelemetry dependencies**<br></br> From VMs, there are two ways to send data to SigNoz Cloud.
```bash - [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud)
pip install opentelemetry-distro - [Send traces via OTel Collector binary](#send-traces-via-otel-collector-binary) (recommended)
pip install opentelemetry-exporter-otlp
```
The dependencies included are briefly explained below: #### **Send traces directly to SigNoz Cloud**
`opentelemetry-distro` - The distro provides a mechanism to automatically configure some of the more common options for users. It helps to get started with OpenTelemetry auto-instrumentation quickly. Step 1. Create a virtual environment<br></br>
```bash
python3 -m venv .venv
source .venv/bin/activate
```
`opentelemetry-exporter-otlp` - This library provides a way to install all OTLP exporters. You will need an exporter to send the data to SigNoz. Step 2. Install the OpenTelemetry dependencies
:::note ```bash
💡 The `opentelemetry-exporter-otlp` is a convenience wrapper package to install all OTLP exporters. Currently, it installs: pip install opentelemetry-distro==0.38b0
pip install opentelemetry-exporter-otlp==1.17.0
```
- opentelemetry-exporter-otlp-proto-http <!-- The dependencies included are briefly explained below:
- opentelemetry-exporter-otlp-proto-grpc
- (soon) opentelemetry-exporter-otlp-json-http `opentelemetry-distro` - The distro provides a mechanism to automatically configure some of the more common options for users. It helps to get started with OpenTelemetry auto-instrumentation quickly.
The `opentelemetry-exporter-otlp-proto-grpc` package installs the gRPC exporter which depends on the `grpcio` package. The installation of `grpcio` may fail on some platforms for various reasons. If you run into such issues, or you don't want to use gRPC, you can install the HTTP exporter instead by installing the `opentelemetry-exporter-otlp-proto-http` package. You need to set the `OTEL_EXPORTER_OTLP_PROTOCOL` environment variable to `http/protobuf` to use the HTTP exporter. `opentelemetry-exporter-otlp` - This library provides a way to install all OTLP exporters. You will need an exporter to send the data to SigNoz.
:::
3. **Add automatic instrumentation**<br></br> :::note
The below command inspects the dependencies of your application and installs the instrumentation packages relevant for your Falcon application. 💡 The `opentelemetry-exporter-otlp` is a convenience wrapper package to install all OTLP exporters. Currently, it installs:
```bash - opentelemetry-exporter-otlp-proto-http
opentelemetry-bootstrap --action=install - opentelemetry-exporter-otlp-proto-grpc
```
:::note - (soon) opentelemetry-exporter-otlp-json-http
Please make sure that you have installed all the dependencies of your application before running the above command. The command will not install instrumentation for the dependencies which are not installed.
:::
4. **Run your application**<br></br> The `opentelemetry-exporter-otlp-proto-grpc` package installs the gRPC exporter which depends on the `grpcio` package. The installation of `grpcio` may fail on some platforms for various reasons. If you run into such issues, or you don't want to use gRPC, you can install the HTTP exporter instead by installing the `opentelemetry-exporter-otlp-proto-http` package. You need to set the `OTEL_EXPORTER_OTLP_PROTOCOL` environment variable to `http/protobuf` to use the HTTP exporter.
In the final run command, you can configure environment variables and flags. Flags for exporters:<br></br> ::: -->
For running your application, there are a few things that you need to keep in mind. Below are the notes: Step 3. Add automatic instrumentation
:::note
Dont run app in reloader/hot-reload mode as it breaks instrumentation.
:::
For running applications with application servers which are based on [pre fork model](#running-applications-with-gunicorn-uwsgi), like Gunicorn, uWSGI you have to add a post_fork hook or a @postfork decorator in your configuration. ```bash
opentelemetry-bootstrap --action=install
```
To start sending data to SigNoz, use the following run command: Please make sure that you have installed all the dependencies of your application before running the above command. The command will not install instrumentation for the dependencies which are not installed.
```bash Step 4. Run your application
OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> OTEL_EXPORTER_OTLP_ENDPOINT="http://<IP of SigNoz Backend>:4317" OTEL_EXPORTER_OTLP_PROTOCOL=grpc opentelemetry-instrument <your run command>
```
*<service_name>* is the name of service you want ```bash
OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.{region}.signoz.cloud:443" \
OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=SIGNOZ_INGESTION_KEY" \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc \
opentelemetry-instrument <your_run_command>
```
*<your_run_command>* can be `python3 app.py` or `flask run` - *`<service_name>`* is the name of the service you want
- *<your_run_command>* can be `python3 app.py` or `flask run`
- Replace `SIGNOZ_INGESTION_KEY` with the api token provided by SigNoz. You can find it in the email sent by SigNoz with your cloud account details.
`IP of SigNoz backend` is the IP of the machine where you installed SigNoz. If you have installed SigNoz on `localhost`, the endpoint will be `http://localhost:4317` for gRPC exporter and `http://localhost:4318` for HTTP exporter. Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
:::note US - ingest.us.signoz.cloud:443 <br></br>
The port numbers are 4317 and 4318 for the gRPC and HTTP exporters respectively. Remember to allow incoming requests to port **4317**/**4318** of machine where SigNoz backend is hosted.
:::
### Validating instrumentation by checking for traces IN - ingest.in.signoz.cloud:443 <br></br>
With your application running, you can verify that youve instrumented your application with OpenTelemetry correctly by confirming that tracing data is being reported to SigNoz. EU - ingest.eu.signoz.cloud:443 <br></br>
To do this, you need to ensure that your application generates some data. Applications will not produce traces unless they are being interacted with, and OpenTelemetry will often buffer data before sending. So you need to interact with your application and wait for some time to see your tracing data in SigNoz. Note:
Dont run app in reloader/hot-reload mode as it breaks instrumentation. For example, you can disable the auto reload with `--noreload`.
Validate your traces in SigNoz: ---
1. Trigger an action in your app that generates a web request. Hit the endpoint a number of times to generate some data. Then, wait for some time. #### **Send traces via OTel Collector binary**
2. In SigNoz, open the `Services` tab. Hit the `Refresh` button on the top right corner, and your application should appear in the list of `Applications`.
3. Go to the `Traces` tab, and apply relevant filters to see your applications traces.
You might see other dummy applications if youre using SigNoz for the first time. You can remove it by following the docs [here](https://signoz.io/docs/operate/docker-standalone/#remove-the-sample-application). OTel Collector binary helps to collect logs, hostmetrics, resource and infra attributes. It is recommended to install Otel Collector binary to collect and send traces to SigNoz cloud. You can correlate signals and have rich contextual data through this way.
<figure data-zoomable align='center'> You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Python application.
<img src="/img/docs/opentelemetry_python_app_instrumented.webp" alt="Python Application in the list of services being monitored in SigNoz"/>
<figcaption><i>Python Application in the list of services being monitored in SigNoz</i></figcaption></figure> Step 1. Create a virtual environment<br></br>
<br></br>
```bash
python3 -m venv .venv
source .venv/bin/activate
```
Step 2. Install the OpenTelemetry dependencies
```bash
pip install opentelemetry-distro==0.38b0
pip install opentelemetry-exporter-otlp==1.17.0
```
Step 3. Add automatic instrumentation
```bash
opentelemetry-bootstrap --action=install
```
Please make sure that you have installed all the dependencies of your application before running the above command. The command will not install instrumentation for the dependencies which are not installed.
Step 4. To run your application and send data to collector in same VM:
```bash
OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317" \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc opentelemetry-instrument <your run command>
```
Note:
Dont run app in reloader/hot-reload mode as it breaks instrumentation.
*<service_name>* is the name of service you want
*<your_run_command>* can be `python3 app.py` or `flask run`
`http://localhost:4317` for gRPC exporter and `http://localhost:4318` for HTTP exporter.
Note:
The port numbers are 4317 and 4318 for the gRPC and HTTP exporters respectively.
In case you have OtelCollector Agent in different VM, replace localhost:4317 with `<IP Address of the VM>:4317`.
---
### Applications Deployed on Kubernetes
For Python application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](https://signoz.io/docs/tutorial/kubernetes-infra-metrics/).
Once you have set up OTel Collector agent, you can proceed with OpenTelemetry Python instrumentation by following the below steps:
Step 1. Create a virtual environment<br></br>
```bash
python3 -m venv .venv
source .venv/bin/activate
```
Step 2. Install the OpenTelemetry dependencies
```bash
pip install opentelemetry-distro==0.38b0
pip install opentelemetry-exporter-otlp==1.17.0
```
Step 3. Add automatic instrumentation
```bash
opentelemetry-bootstrap --action=install
```
Please make sure that you have installed all the dependencies of your application before running the above command. The command will not install instrumentation for the dependencies which are not installed.
Step 4. Run your application:
```bash
OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317" \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc opentelemetry-instrument <your run command>
```
Note:
Dont run app in reloader/hot-reload mode as it breaks instrumentation.
*<service_name>* is the name of service you want
*<your_run_command>* can be `python3 app.py` or `flask run`
`http://localhost:4317` for gRPC exporter and `http://localhost:4318` for HTTP exporter.
Note:
The port numbers are 4317 and 4318 for the gRPC and HTTP exporters respectively.
In case you have OtelCollector Agent in different VM, replace localhost:4317 with `<IP Address of the VM>:4317`.
Step 5. Make sure to dockerise your application along with OpenTelemetry instrumentation.

View File

@ -1,92 +1,163 @@
## Send Traces Directly to SigNoz ## Requirements
You can use OpenTelemetry to send your traces directly to SigNoz. OpenTelemetry provides a handy distro in Python that can help you get started with automatic instrumentation. We recommend using it to get started quickly. - Python 3.8 or newer
### Steps to auto-instrument FastAPI app for traces ## Send Traces to SigNoz Cloud
1. **Create a virtual environment**<br></br> Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud.
```bash ### Application on VMs
python3 -m venv .venv
source .venv/bin/activate
```
2. **Install the OpenTelemetry dependencies**<br></br> From VMs, there are two ways to send data to SigNoz Cloud.
```bash - [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud)
pip install opentelemetry-distro - [Send traces via OTel Collector binary](#send-traces-via-otel-collector-binary) (recommended)
pip install opentelemetry-exporter-otlp
```
The dependencies included are briefly explained below: #### **Send traces directly to SigNoz Cloud**
`opentelemetry-distro` - The distro provides a mechanism to automatically configure some of the more common options for users. It helps to get started with OpenTelemetry auto-instrumentation quickly. Step 1. Create a virtual environment<br></br>
```bash
python3 -m venv .venv
source .venv/bin/activate
```
`opentelemetry-exporter-otlp` - This library provides a way to install all OTLP exporters. You will need an exporter to send the data to SigNoz. Step 2. Install the OpenTelemetry dependencies
:::note ```bash
💡 The `opentelemetry-exporter-otlp` is a convenience wrapper package to install all OTLP exporters. Currently, it installs: pip install opentelemetry-distro==0.38b0
pip install opentelemetry-exporter-otlp==1.17.0
```
- opentelemetry-exporter-otlp-proto-http Step 3. Add automatic instrumentation
- opentelemetry-exporter-otlp-proto-grpc
- (soon) opentelemetry-exporter-otlp-json-http ```bash
opentelemetry-bootstrap --action=install
```
The `opentelemetry-exporter-otlp-proto-grpc` package installs the gRPC exporter which depends on the `grpcio` package. The installation of `grpcio` may fail on some platforms for various reasons. If you run into such issues, or you don't want to use gRPC, you can install the HTTP exporter instead by installing the `opentelemetry-exporter-otlp-proto-http` package. You need to set the `OTEL_EXPORTER_OTLP_PROTOCOL` environment variable to `http/protobuf` to use the HTTP exporter. Please make sure that you have installed all the dependencies of your application before running the above command. The command will not install instrumentation for the dependencies which are not installed.
:::
3. **Add automatic instrumentation**<br></br> Step 4. Run your application
The below command inspects the dependencies of your application and installs the instrumentation packages relevant for your FastAPI application.
```bash ```bash
opentelemetry-bootstrap --action=install OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \
``` OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.{region}.signoz.cloud:443" \
OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=SIGNOZ_INGESTION_KEY" \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc \
opentelemetry-instrument <your_run_command>
```
:::note - *`<service_name>`* is the name of the service you want
Please make sure that you have installed all the dependencies of your application before running the above command. The command will not install instrumentation for the dependencies which are not installed. - *<your_run_command>* can be `python3 app.py` or `python manage.py runserver --noreload`
::: - Replace `SIGNOZ_INGESTION_KEY` with the api token provided by SigNoz. You can find it in the email sent by SigNoz with your cloud account details.
4. **Run your application**<br></br> Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
In the final run command, you can configure environment variables and flags. Flags for exporters:<br></br>
For running your application, there are a few things that you need to keep in mind. Below are the notes: US - ingest.us.signoz.cloud:443 <br></br>
:::note
Dont run app in reloader/hot-reload mode as it breaks instrumentation. For example, if you use `--reload` or `reload=True`, it enables the reloader mode which breaks OpenTelemetry isntrumentation.
:::
For running applications with application servers which are based on [pre fork model](#running-applications-with-gunicorn-uwsgi), like Gunicorn, uWSGI you have to add a post_fork hook or a @postfork decorator in your configuration. IN - ingest.in.signoz.cloud:443 <br></br>
To start sending data to SigNoz, use the following run command: EU - ingest.eu.signoz.cloud:443 <br></br>
```bash Note:
OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> OTEL_EXPORTER_OTLP_ENDPOINT="http://<IP of SigNoz Backend>:4317" OTEL_EXPORTER_OTLP_PROTOCOL=grpc opentelemetry-instrument <your run command> Dont run app in reloader/hot-reload mode as it breaks instrumentation. For example, you can disable the auto reload with `--noreload`.
```
*<service_name>* is the name of service you want ---
*<your_run_command>* can be `python3 app.py` or `python manage.py runserver --noreload` #### **Send traces via OTel Collector binary**
`IP of SigNoz backend` is the IP of the machine where you installed SigNoz. If you have installed SigNoz on `localhost`, the endpoint will be `http://localhost:4317` for gRPC exporter and `http://localhost:4318` for HTTP exporter. OTel Collector binary helps to collect logs, hostmetrics, resource and infra attributes. It is recommended to install Otel Collector binary to collect and send traces to SigNoz cloud. You can correlate signals and have rich contextual data through this way.
:::note You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Python application.
The port numbers are 4317 and 4318 for the gRPC and HTTP exporters respectively. Remember to allow incoming requests to port **4317**/**4318** of machine where SigNoz backend is hosted.
:::
### Validating instrumentation by checking for traces Step 1. Create a virtual environment<br></br>
```bash
python3 -m venv .venv
source .venv/bin/activate
```
With your application running, you can verify that youve instrumented your application with OpenTelemetry correctly by confirming that tracing data is being reported to SigNoz. Step 2. Install the OpenTelemetry dependencies
To do this, you need to ensure that your application generates some data. Applications will not produce traces unless they are being interacted with, and OpenTelemetry will often buffer data before sending. So you need to interact with your application and wait for some time to see your tracing data in SigNoz. ```bash
pip install opentelemetry-distro==0.38b0
pip install opentelemetry-exporter-otlp==1.17.0
```
Validate your traces in SigNoz: Step 3. Add automatic instrumentation
1. Trigger an action in your app that generates a web request. Hit the endpoint a number of times to generate some data. Then, wait for some time. ```bash
2. In SigNoz, open the `Services` tab. Hit the `Refresh` button on the top right corner, and your application should appear in the list of `Applications`. opentelemetry-bootstrap --action=install
3. Go to the `Traces` tab, and apply relevant filters to see your applications traces. ```
You might see other dummy applications if youre using SigNoz for the first time. You can remove it by following the docs [here](https://signoz.io/docs/operate/docker-standalone/#remove-the-sample-application). Please make sure that you have installed all the dependencies of your application before running the above command. The command will not install instrumentation for the dependencies which are not installed.
<figure data-zoomable align='center'> Step 4. To run your application and send data to collector in same VM:
<img src="/img/docs/opentelemetry_python_app_instrumented.webp" alt="Python Application in the list of services being monitored in SigNoz"/>
<figcaption><i>Python Application in the list of services being monitored in SigNoz</i></figcaption></figure> ```bash
<br></br> OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317" \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc opentelemetry-instrument <your run command>
```
*<service_name>* is the name of service you want
*<your_run_command>* can be `python3 app.py` or `python manage.py runserver --noreload`
`http://localhost:4317` for gRPC exporter and `http://localhost:4318` for HTTP exporter.
Note:
The port numbers are 4317 and 4318 for the gRPC and HTTP exporters respectively.
In case you have OtelCollector Agent in different VM, replace localhost:4317 with `<IP Address of the VM>:4317`.
---
### Applications Deployed on Kubernetes
For Python application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](https://signoz.io/docs/tutorial/kubernetes-infra-metrics/).
Once you have set up OTel Collector agent, you can proceed with OpenTelemetry Python instrumentation by following the below steps:
Step 1. Create a virtual environment<br></br>
```bash
python3 -m venv .venv
source .venv/bin/activate
```
Step 2. Install the OpenTelemetry dependencies
```bash
pip install opentelemetry-distro==0.38b0
pip install opentelemetry-exporter-otlp==1.17.0
```
Step 3. Add automatic instrumentation
```bash
opentelemetry-bootstrap --action=install
```
Please make sure that you have installed all the dependencies of your application before running the above command. The command will not install instrumentation for the dependencies which are not installed.
Step 4. Run your application:
```bash
OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317" \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc opentelemetry-instrument <your run command>
```
*<service_name>* is the name of service you want
*<your_run_command>* can be `python3 app.py` or `python manage.py runserver --noreload`
`http://localhost:4317` for gRPC exporter and `http://localhost:4318` for HTTP exporter.
Note:
The port numbers are 4317 and 4318 for the gRPC and HTTP exporters respectively.
In case you have OtelCollector Agent in different VM, replace localhost:4317 with `<IP Address of the VM>:4317`.
Step 5. Make sure to dockerise your application along with OpenTelemetry instrumentation.

View File

@ -1,92 +1,168 @@
## Send Traces Directly to SigNoz ## Requirements
You can use OpenTelemetry to send your traces directly to SigNoz. OpenTelemetry provides a handy distro in Python that can help you get started with automatic instrumentation. We recommend using it to get started quickly. - Python 3.8 or newer
### Steps to auto-instrument Flask app for traces ## Send Traces to SigNoz Cloud
1. **Create a virtual environment**<br></br> Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud.
```bash ### Application on VMs
python3 -m venv .venv
source .venv/bin/activate
```
2. **Install the OpenTelemetry dependencies**<br></br> From VMs, there are two ways to send data to SigNoz Cloud.
```bash - [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud)
pip install opentelemetry-distro - [Send traces via OTel Collector binary](#send-traces-via-otel-collector-binary) (recommended)
pip install opentelemetry-exporter-otlp
```
The dependencies included are briefly explained below: #### **Send traces directly to SigNoz Cloud**
`opentelemetry-distro` - The distro provides a mechanism to automatically configure some of the more common options for users. It helps to get started with OpenTelemetry auto-instrumentation quickly. Step 1. Create a virtual environment<br></br>
```bash
python3 -m venv .venv
source .venv/bin/activate
```
`opentelemetry-exporter-otlp` - This library provides a way to install all OTLP exporters. You will need an exporter to send the data to SigNoz. Step 2. Install the OpenTelemetry dependencies
:::note ```bash
💡 The `opentelemetry-exporter-otlp` is a convenience wrapper package to install all OTLP exporters. Currently, it installs: pip install opentelemetry-distro==0.38b0
pip install opentelemetry-exporter-otlp==1.17.0
```
- opentelemetry-exporter-otlp-proto-http Step 3. Add automatic instrumentation
- opentelemetry-exporter-otlp-proto-grpc
- (soon) opentelemetry-exporter-otlp-json-http ```bash
opentelemetry-bootstrap --action=install
```
The `opentelemetry-exporter-otlp-proto-grpc` package installs the gRPC exporter which depends on the `grpcio` package. The installation of `grpcio` may fail on some platforms for various reasons. If you run into such issues, or you don't want to use gRPC, you can install the HTTP exporter instead by installing the `opentelemetry-exporter-otlp-proto-http` package. You need to set the `OTEL_EXPORTER_OTLP_PROTOCOL` environment variable to `http/protobuf` to use the HTTP exporter. Please make sure that you have installed all the dependencies of your application before running the above command. The command will not install instrumentation for the dependencies which are not installed.
:::
3. **Add automatic instrumentation**<br></br> Step 4. Run your application
The below command inspects the dependencies of your application and installs the instrumentation packages relevant for your Flask application.
```bash ```bash
opentelemetry-bootstrap --action=install OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \
``` OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.{region}.signoz.cloud:443" \
OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=SIGNOZ_INGESTION_KEY" \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc \
opentelemetry-instrument <your_run_command>
```
:::note - *`<service_name>`* is the name of the service you want
Please make sure that you have installed all the dependencies of your application before running the above command. The command will not install instrumentation for the dependencies which are not installed. - *<your_run_command>* can be `python3 app.py` or `flask run`
::: - Replace `SIGNOZ_INGESTION_KEY` with the api token provided by SigNoz. You can find it in the email sent by SigNoz with your cloud account details.
4. **Run your application**<br></br> Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
In the final run command, you can configure environment variables and flags. Flags for exporters:<br></br>
For running your application, there are a few things that you need to keep in mind. Below are the notes: US - ingest.us.signoz.cloud:443 <br></br>
:::note
Dont run app in reloader/hot-reload mode as it breaks instrumentation. For example, if you use `export Flask_ENV=development`, it enables the reloader mode which breaks OpenTelemetry instrumentation.
:::
For running applications with application servers which are based on [pre fork model](#running-applications-with-gunicorn-uwsgi), like Gunicorn, uWSGI you have to add a post_fork hook or a @postfork decorator in your configuration. IN - ingest.in.signoz.cloud:443 <br></br>
To start sending data to SigNoz, use the following run command: EU - ingest.eu.signoz.cloud:443 <br></br>
```bash Note:
OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> OTEL_EXPORTER_OTLP_ENDPOINT="http://<IP of SigNoz Backend>:4317" OTEL_EXPORTER_OTLP_PROTOCOL=grpc opentelemetry-instrument <your run command> Dont run app in reloader/hot-reload mode as it breaks instrumentation. For example, you can disable the auto reload with `--noreload`.
```
*<service_name>* is the name of service you want ---
*<your_run_command>* can be `python3 app.py` or `flask run` #### **Send traces via OTel Collector binary**
`IP of SigNoz backend` is the IP of the machine where you installed SigNoz. If you have installed SigNoz on `localhost`, the endpoint will be `http://localhost:4317` for gRPC exporter and `http://localhost:4318` for HTTP exporter. OTel Collector binary helps to collect logs, hostmetrics, resource and infra attributes. It is recommended to install Otel Collector binary to collect and send traces to SigNoz cloud. You can correlate signals and have rich contextual data through this way.
:::note You can find instructions to install OTel Collector binary [here](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/) in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Python application.
The port numbers are 4317 and 4318 for the gRPC and HTTP exporters respectively. Remember to allow incoming requests to port **4317**/**4318** of machine where SigNoz backend is hosted.
:::
### Validating instrumentation by checking for traces Step 1. Create a virtual environment<br></br>
```bash
python3 -m venv .venv
source .venv/bin/activate
```
With your application running, you can verify that youve instrumented your application with OpenTelemetry correctly by confirming that tracing data is being reported to SigNoz. Step 2. Install the OpenTelemetry dependencies
To do this, you need to ensure that your application generates some data. Applications will not produce traces unless they are being interacted with, and OpenTelemetry will often buffer data before sending. So you need to interact with your application and wait for some time to see your tracing data in SigNoz. ```bash
pip install opentelemetry-distro==0.38b0
pip install opentelemetry-exporter-otlp==1.17.0
```
Validate your traces in SigNoz: Step 3. Add automatic instrumentation
1. Trigger an action in your app that generates a web request. Hit the endpoint a number of times to generate some data. Then, wait for some time. ```bash
2. In SigNoz, open the `Services` tab. Hit the `Refresh` button on the top right corner, and your application should appear in the list of `Applications`. opentelemetry-bootstrap --action=install
3. Go to the `Traces` tab, and apply relevant filters to see your applications traces. ```
You might see other dummy applications if youre using SigNoz for the first time. You can remove it by following the docs [here](https://signoz.io/docs/operate/docker-standalone/#remove-the-sample-application). Please make sure that you have installed all the dependencies of your application before running the above command. The command will not install instrumentation for the dependencies which are not installed.
<figure data-zoomable align='center'> Step 4. To run your application and send data to collector in same VM:
<img src="/img/docs/opentelemetry_python_app_instrumented.webp" alt="Python Application in the list of services being monitored in SigNoz"/>
<figcaption><i>Python Application in the list of services being monitored in SigNoz</i></figcaption></figure> ```bash
<br></br> OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317" \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc opentelemetry-instrument <your run command>
```
Note:
Dont run app in reloader/hot-reload mode as it breaks instrumentation. For example, if you use `export Flask_ENV=development`, it enables the reloader mode which breaks OpenTelemetry instrumentation.
*<service_name>* is the name of service you want
*<your_run_command>* can be `python3 app.py` or `flask run`
`http://localhost:4317` for gRPC exporter and `http://localhost:4318` for HTTP exporter.
The port numbers are 4317 and 4318 for the gRPC and HTTP exporters respectively.
In case you have OtelCollector Agent in different VM, replace localhost:4317 with `<IP Address of the VM>:4317`.
---
### Applications Deployed on Kubernetes
For Python application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](https://signoz.io/docs/tutorial/kubernetes-infra-metrics/).
Once you have set up OTel Collector agent, you can proceed with OpenTelemetry Python instrumentation by following the below steps:
Step 1. Create a virtual environment<br></br>
```bash
python3 -m venv .venv
source .venv/bin/activate
```
Step 2. Install the OpenTelemetry dependencies
```bash
pip install opentelemetry-distro==0.38b0
pip install opentelemetry-exporter-otlp==1.17.0
```
Step 3. Add automatic instrumentation
```bash
opentelemetry-bootstrap --action=install
```
Please make sure that you have installed all the dependencies of your application before running the above command. The command will not install instrumentation for the dependencies which are not installed.
Step 4. Run your application:
```bash
OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317" \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc opentelemetry-instrument <your run command>
```
Note:
Dont run app in reloader/hot-reload mode as it breaks instrumentation. For example, if you use `export Flask_ENV=development`, it enables the reloader mode which breaks OpenTelemetry instrumentation.
*<service_name>* is the name of service you want
*<your_run_command>* can be `python3 app.py` or `flask run`
`http://localhost:4317` for gRPC exporter and `http://localhost:4318` for HTTP exporter.
The port numbers are 4317 and 4318 for the gRPC and HTTP exporters respectively.
In case you have OtelCollector Agent in different VM, replace localhost:4317 with `<IP Address of the VM>:4317`.
Step 5. Make sure to dockerise your application along with OpenTelemetry instrumentation.

View File

@ -1,7 +1,13 @@
## Requirements
- Python 3.8 or newer
## Send Traces to SigNoz Cloud ## Send Traces to SigNoz Cloud
Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud. Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud.
### Application on VMs
From VMs, there are two ways to send data to SigNoz Cloud. From VMs, there are two ways to send data to SigNoz Cloud.
- [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud) - [Send traces directly to SigNoz Cloud](#send-traces-directly-to-signoz-cloud)
@ -37,13 +43,14 @@ opentelemetry-instrument <your_run_command>
Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table. Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
| Region | Endpoint | US - ingest.us.signoz.cloud:443 <br></br>
| ------ | -------------------------- |
| US | ingest.us.signoz.cloud:443 |
| IN | ingest.in.signoz.cloud:443 |
| EU | ingest.eu.signoz.cloud:443 |
Step 4. Validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces). IN - ingest.in.signoz.cloud:443 <br></br>
EU - ingest.eu.signoz.cloud:443 <br></br>
Note:
Dont run app in reloader/hot-reload mode as it breaks instrumentation.
--- ---
@ -71,7 +78,7 @@ Step 3. To run your application and send data to collector in same VM:
```bash ```bash
OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \ OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317" \ OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317" \
opentelemetry-instrument <your_run_command> OTEL_EXPORTER_OTLP_PROTOCOL=grpc opentelemetry-instrument <your run command>
``` ```
where, where,
@ -79,9 +86,20 @@ where,
- *`<service_name>`* is the name of the service you want - *`<service_name>`* is the name of the service you want
- *`<your_run_command>`* can be `python3 app.py` or `flask run` - *`<your_run_command>`* can be `python3 app.py` or `flask run`
*<service_name>* is the name of service you want
*<your_run_command>* can be `python3 app.py` or `flask run`
`http://localhost:4317` for gRPC exporter and `http://localhost:4318` for HTTP exporter.
The port numbers are 4317 and 4318 for the gRPC and HTTP exporters respectively.
In case you have OtelCollector Agent in different VM, replace localhost:4317 with `<IP Address of the VM>:4317`. In case you have OtelCollector Agent in different VM, replace localhost:4317 with `<IP Address of the VM>:4317`.
Step 4. You can validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces). ---
### Applications Deployed on Kubernetes
For Python application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](https://signoz.io/docs/tutorial/kubernetes-infra-metrics/). For Python application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent [here](https://signoz.io/docs/tutorial/kubernetes-infra-metrics/).
@ -105,7 +123,7 @@ Step 3. Run your application:
```bash ```bash
OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \ OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317" \ OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317" \
opentelemetry-instrument <your_run_command> OTEL_EXPORTER_OTLP_PROTOCOL=grpc opentelemetry-instrument <your run command>
``` ```
where, where,
@ -113,6 +131,5 @@ where,
- *`<service_name>`* is the name of the service you want - *`<service_name>`* is the name of the service you want
- *`<your_run_command>`* can be `python3 app.py` or `flask run` - *`<your_run_command>`* can be `python3 app.py` or `flask run`
Step 4. Make sure to dockerise your application along with OpenTelemetry instrumentation.
You can validate if your application is sending traces to SigNoz cloud by following the instructions [here](#validating-instrumentation-by-checking-for-traces). Step 4. Make sure to dockerise your application along with OpenTelemetry instrumentation.

View File

@ -1,82 +1,35 @@
import './InfrastructureMonitoring.styles.scss'; import './InfrastructureMonitoring.styles.scss';
import { MDXProvider } from '@mdx-js/react'; import { MDXProvider } from '@mdx-js/react';
import { Tabs } from 'antd';
import Prometheus from './prometheus.md'; import InfraMonitoringDocs from './infraMonitoringDocs.md';
import SpecificReceiver from './specific-metric-receiver.md';
const enum ReceiverType {
specific_metric_receiver = 'Specific Metric Receiver',
Prometheus = 'Prometheus',
}
const supportedLanguages = [
{
name: 'specific_metric_receiver',
label: 'Specific Metric Receiver',
},
{
name: 'prometheus',
label: 'Prometheus',
},
];
export default function InfrastructureMonitoring({ export default function InfrastructureMonitoring({
activeStep, activeStep,
}: { }: {
activeStep: number; activeStep: number;
}): JSX.Element { }): JSX.Element {
const renderEnableReceiverByType = (receiverType: string): JSX.Element => { const docsURL = 'https://signoz.io/docs/userguide/send-metrics-cloud/';
if (receiverType === ReceiverType.specific_metric_receiver) { const heading = 'Send Metrics to SigNoz Cloud';
return <SpecificReceiver />;
}
return <Prometheus />;
};
return ( return (
<div className="infrastructure-monitoring-module-container"> <div className="infrastructure-monitoring-module-container">
{activeStep === 2 && ( {activeStep === 2 && (
<div className="content-container"> <div className="content-container">
<div className="heading"> <div className="header">
<h2 className="title"> <div className="title">
By default, when you install SigNoz, only the &nbsp; <h1>{heading}</h1>
<a
target="_blank"
rel="noreferrer"
href="https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/hostmetricsreceiver/README.md"
>
Hostmetric receiver
</a>
&nbsp; is enabled.
</h2>
</div>
<div className="subheading"> <div className="detailed-docs-link">
Before you can query other metrics, you must first enable additional View detailed docs
receivers in SigNoz. There are two ways in which you can send metrics to <a target="_blank" href={docsURL} rel="noreferrer">
SigNoz using OpenTelemetry: here
<br /> </a>
<div className="recevier-types"> </div>
<small> 1. Enable a Specific Metric Receiver </small>
<small> 2. Enable a Prometheus Receiver </small>
</div> </div>
</div> </div>
<MDXProvider> <MDXProvider>
<Tabs <InfraMonitoringDocs />
defaultActiveKey="1"
items={supportedLanguages.map((language, i) => {
const id = String(i + 1);
return {
label: <div className="language-tab-item">{language.label}</div>,
key: id,
children: renderEnableReceiverByType(language.name),
};
})}
/>
</MDXProvider> </MDXProvider>
</div> </div>
)} )}

View File

@ -0,0 +1,191 @@
There are two ways in which you can send metrics to SigNoz using OpenTelemetry:
- From your application
- From OpenTelemetry Collector
In this document, we will cover how to send metrics from OpenTelemetry Collector. The Collector is a swiss-army knife that can collect metrics from various sources and send them to SigNoz.
- [Enable a Specific Metric Receiver](#enable-a-specific-metric-receiver)
- [Enable a Prometheus Receiver](#enable-a-prometheus-receiver)
## Enable a Specific Metric Receiver
SigNoz supports all the receivers that are listed in the [opentelemetry-collector-contrib](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver) GitHub repository. To configure a new metric receiver, you must edit the `receivers` and `service::pipelines` sections of the `otel-collector-config.yaml` file. The following example shows the default configuration in which the `hostmetrics` receiver is enabled:
```yaml {8-20,52}
receivers:
otlp:
protocols:
grpc:
endpoint: localhost:4317
http:
endpoint: localhost:4318
hostmetrics:
collection_interval: 30s
scrapers:
cpu: {}
disk: {}
load: {}
filesystem: {}
memory: {}
network: {}
paging: {}
process:
mute_process_name_error: true
processes: {}
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, ec2] # include ec2 for AWS, gce for GCP and azure for Azure.
# Using OTEL_RESOURCE_ATTRIBUTES envvar, env detector adds custom labels.
timeout: 2s
override: false
system:
hostname_sources: [os] # alternatively, use [dns,os] for setting FQDN as host.name and os as fallback
exporters:
otlp:
endpoint: 'ingest.{region}.signoz.cloud:443' # replace {region} with your region
tls:
insecure: false
headers:
'signoz-access-token': '<SIGNOZ_INGESTION_KEY>'
logging:
loglevel: debug
service:
telemetry:
metrics:
address: localhost:8888
pipelines:
metrics:
receivers: [otlp]
processors: [batch]
exporters: [otlp]
metrics/hostmetrics:
receivers: [hostmetrics]
processors: [resourcedetection, batch]
exporters: [otlp]
```
Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
US - ingest.us.signoz.cloud:443 <br></br>
IN - ingest.in.signoz.cloud:443 <br></br>
EU - ingest.eu.signoz.cloud:443 <br></br>
To enable a new OpenTelemetry receiver, follow the steps below:
1. Open the `otel-collector-config.yaml` file in a plain-text editor.
2. Configure your receivers. The following example shows how you can enable a `rabbitmq` receiver:
```yaml {21-25,53}
receivers:
otlp:
protocols:
grpc:
endpoint: localhost:4317
http:
endpoint: localhost:4318
hostmetrics:
collection_interval: 30s
scrapers:
cpu: {}
disk: {}
load: {}
filesystem: {}
memory: {}
network: {}
paging: {}
process:
mute_process_name_error: true
processes: {}
rabbitmq:
endpoint: http://localhost:15672
username: <RABBITMQ_USERNAME>
password: <RABBITMQ_PASSWORD>
collection_interval: 10s
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, ec2] # include ec2 for AWS, gce for GCP and azure for Azure.
# Using OTEL_RESOURCE_ATTRIBUTES envvar, env detector adds custom labels.
timeout: 2s
override: false
system:
hostname_sources: [os] # alternatively, use [dns,os] for setting FQDN as host.name and os as fallback
exporters:
otlp:
endpoint: 'ingest.{region}.signoz.cloud:443' # replace {region} with your region
tls:
insecure: false
headers:
'signoz-access-token': '<SIGNOZ_INGESTION_KEY>'
logging:
loglevel: debug
service:
telemetry:
metrics:
address: localhost:8888
pipelines:
metrics:
receivers: [otlp, rabbitmq]
processors: [batch]
exporters: [otlp]
metrics/hostmetrics:
receivers: [hostmetrics]
processors: [resourcedetection, batch]
exporters: [otlp]
```
For details about configuring OpenTelemetry receivers, see the [README](https://github.com/open-telemetry/opentelemetry-collector/blob/main/receiver/README.md) page of the `opentelemetry-collector` GitHub repository.
## Enable a Prometheus Receiver
SigNoz supports all the exporters that are listed on the [Exporters and Integrations](https://prometheus.io/docs/instrumenting/exporters/) page of the Prometheus documentation. If you have a running Prometheus instance, and you expose metrics in Prometheus, then you can scrape them in SigNoz by configuring Prometheus receivers in the `receivers::prometheus::config::scrape_configs` section of the `otel-collector-config.yaml` file.
To enable a Prometheus receiver, follow the steps below:
1. Open the `otel-collector-config.yaml` file in a plain-text editor.
2. Enable a new Prometheus receiver. Depending on your use case, there are two ways in which you can enable a new Prometheus exporter:
- **By creating a new job**: The following example shows how you can enable a Prometheus receiver by creating a new job named `my-new-job`:
```yaml {10-13}
...
# Data sources: metrics
prometheus:
config:
scrape_configs:
- job_name: "otel-collector"
scrape_interval: 30s
static_configs:
- targets: ["otel-collector:8889"]
- job_name: "my-new-job"
scrape_interval: 30s
static_configs:
- targets: ["localhost:8080"]
...
# This file was truncated for brevity.
```
- **By adding a new target to an existing job**: The following example shows the default `otel-collector` job to which a new target (`localhost:8080`) was added:
```yaml {9}
...
# Data sources: metrics
prometheus:
config:
scrape_configs:
- job_name: "otel-collector"
scrape_interval: 30s
static_configs:
- targets: ["otel-collector:8889", "localhost:8080"]
...
# This file was truncated for brevity.
```
Note that all the jobs are scraped in parallel, and all targets inside a job are scraped serially. For more details about configuring jobs and targets, see the following sections of the Prometheus documentation:
- [<Scrape_config>](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config)
- [Jobs and Instances](https://prometheus.io/docs/concepts/jobs_instances/)

View File

@ -1,67 +0,0 @@
## Enable a Prometheus Receiver
SigNoz supports all the exporters that are listed on the [Exporters and Integrations](https://prometheus.io/docs/instrumenting/exporters/) page of the Prometheus documentation. If you have a running Prometheus instance, and you expose metrics in Prometheus, then you can scrape them in SigNoz by configuring Prometheus receivers in the `receivers.prometheus.config.scrape_configs` section of the `deploy/docker/clickhouse-setup/otel-collector-metrics-config.yaml` file.
To enable a Prometheus receiver, follow the steps below:
1. Open the `deploy/docker/clickhouse-setup/otel-collector-metrics-config.yaml` file in a plain-text editor.
2. Enable a new Prometheus receiver. Depending on your use case, there are two ways in which you can enable a new Prometheus exporter:
- **By creating a new job**: The following example shows how you can enable a Prometheus receiver by creating a new job named `my-new-job`:
```yaml {15-18}
receivers:
otlp:
protocols:
grpc:
http:
# Data sources: metrics
prometheus:
config:
scrape_configs:
- job_name: 'otel-collector'
scrape_interval: 30s
static_configs:
- targets: ['otel-collector:8889']
- job_name: 'my-new-job'
scrape_interval: 30s
static_configs:
- targets: ['localhost:8080']
processors:
batch:
send_batch_size: 1000
timeout: 10s
# This file was truncated for brevity.
```
- **By adding a new target to an existing job**: The following example shows the default `otel-collector` job to which a new target (`localhost:8080`) was added:
```yaml {14}
receivers:
otlp:
protocols:
grpc:
http:
# Data sources: metrics
prometheus:
config:
scrape_configs:
- job_name: 'otel-collector'
scrape_interval: 30s
static_configs:
- targets: ['otel-collector:8889', 'localhost:8080']
processors:
batch:
send_batch_size: 1000
timeout: 10s
# This file was truncated for brevity.
```
Note that all the jobs are scraped in parallel, and all targets inside a job are scraped serially. For more details about configuring jobs and targets, see the following sections of the Prometheus documentation:
- [<Scrape_config>](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config)
- [Jobs and Instances](https://prometheus.io/docs/concepts/jobs_instances/)
3. <SaveChangesRestart />

View File

@ -1,72 +0,0 @@
## Enable a Specific Metric Receiver
SigNoz supports all the receivers that are listed in the [opentelemetry-collector-contrib](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver) GitHub repository. To configure a new metric receiver, you must edit the `receivers` section of the `deploy/docker/clickhouse-setup/otel-collector-config.yaml` file. The following example shows the default configuration in which the `hostmetrics` receiver is enabled:
```yaml {14-22}
receivers:
otlp/spanmetrics:
protocols:
grpc:
endpoint: 'localhost:12345'
otlp:
protocols:
grpc:
http:
jaeger:
protocols:
grpc:
thrift_http:
hostmetrics:
collection_interval: 30s
scrapers:
cpu:
load:
memory:
disk:
filesystem:
network:
processors:
batch:
send_batch_size: 1000
timeout: 10s
# This file was truncated for brevity
```
To enable a new OpenTelemetry receiver, follow the steps below:
1. Move into the directory in which you installed SigNoz, and open the `deploy/docker/clickhouse-setup/otel-collector-config.yaml` file in a plain-text editor.
2. Configure your receivers. The following example shows how you can enable a receiver named `examplereceiver`:
```yaml {23,24}
receivers:
otlp/spanmetrics:
protocols:
grpc:
endpoint: 'localhost:12345'
otlp:
protocols:
grpc:
http:
jaeger:
protocols:
grpc:
thrift_http:
hostmetrics:
collection_interval: 30s
scrapers:
cpu:
load:
memory:
disk:
filesystem:
network:
examplereceiver:
endpoint: 1.2.3.4:8080
processors:
batch:
send_batch_size: 1000
timeout: 10s
# This file was truncated for brevity.
```
For details about configuring OpenTelemetry receivers, see the [README](https://github.com/open-telemetry/opentelemetry-collector/blob/main/receiver/README.md) page of the `opentelemetry-collector` GitHub repository. 3. <SaveChangesRestart />

View File

@ -0,0 +1,72 @@
import { MDXProvider } from '@mdx-js/react';
import { Select } from 'antd';
import Header from 'container/OnboardingContainer/common/Header/Header';
import { useState } from 'react';
import FluentBit from './md-docs/fluentBit.md';
import FluentD from './md-docs/fluentD.md';
import LogStashDocs from './md-docs/logStash.md';
enum FrameworksMap {
fluent_d = 'FluentD',
fluent_bit = 'FluentBit',
logstash = 'Logstash',
}
export default function ExistingCollectors(): JSX.Element {
const [selectedFrameWork, setSelectedFrameWork] = useState('fluent_d');
const renderDocs = (): JSX.Element => {
switch (selectedFrameWork) {
case 'fluent_d':
return <FluentD />;
case 'fluent_bit':
return <FluentBit />;
default:
return <LogStashDocs />;
}
};
return (
<div className="java-setup-instructions-container">
<Header
entity="existing_collectors"
heading="Logs from existing collectors"
imgURL="/Logos/cmd-terminal.svg"
docsURL="https://signoz.io/docs/userguide/fluentbit_to_signoz/"
imgClassName="supported-language-img"
/>
<div className="form-container">
<div className="framework-selector">
<div className="label"> Select Framework </div>
<Select
defaultValue="fluent_d"
style={{ minWidth: 120 }}
placeholder="Select Framework"
onChange={(value): void => setSelectedFrameWork(value)}
options={[
{
value: 'fluent_d',
label: FrameworksMap.fluent_d,
},
{
value: 'fluent_bit',
label: FrameworksMap.fluent_bit,
},
{
value: 'logstash',
label: FrameworksMap.logstash,
},
]}
/>
</div>
</div>
<div className="content-container">
<MDXProvider>{renderDocs()}</MDXProvider>
</div>
</div>
);
}

View File

@ -0,0 +1,66 @@
If you use fluentBit to collect logs in your stack with this tutotrial you will be able to send logs from fluentBit to SigNoz.
At SigNoz we use opentelemetry collector to recieve logs which supports the fluentforward protocol. So you can forward your logs from your fluentBit agent to opentelemetry collector using fluentforward protocol.
### Collect Logs Using FluentBit in SigNoz cloud
- Add otel collector binary to your VM by following this [guide](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
- Add fluentforward reciever to your `config.yaml`
```yaml
receivers:
fluentforward:
endpoint: 0.0.0.0:24224
```
Here we have used port 24224 for listing in fluentforward protocol, but you can change it to a port you want.
You can read more about fluentforward receiver [here](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/fluentforwardreceiver).
- Modify your `config.yaml` and add the above receiver
```yaml {4}
service:
....
logs:
receivers: [otlp, fluentforward]
processors: [batch]
exporters: [otlp]
```
- Change the fluentBit config to forward the logs to otel collector.
```
[INPUT]
Name dummy
Tag dummy.log
Dummy {"message": "mylog", "trace_id": "0000000000000000f4dbb3edd765f620", "span_id": "43222c2d51a7abe3"}
[OUTPUT]
Name forward
Match *
Host otel-collector-host
Port 24224
```
In this example we are generating sample logs and then forwarding them to the otel collector which is listening on port 24224.
`otel-collector-host` has to be replaced by the host where otel-collector is running. For more info check [troubleshooting](../install/troubleshooting.md#signoz-otel-collector-address-grid).
- Once you make this changes you can restart fluentBit and otel-binary, and you will be able to see the logs in SigNoz.
- To properly transform your existing log model into opentelemetry [log](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md) model you can use the different processors provided by opentelemetry. [link](./logs.md#processors-available-for-processing-logs)
eg:-
```yaml
processors:
logstransform:
operators:
- type: trace_parser
trace_id:
parse_from: attributes.trace_id
span_id:
parse_from: attributes.span_id
- type: remove
field: attributes.trace_id
- type: remove
field: attributes.span_id
```
The operations in the above processor will parse the trace_id and span_id from log to opentelemetry log model and remove them from attributes.

View File

@ -0,0 +1,79 @@
If you use fluentD to collect logs in your stack with this tutotrial you will be able to send logs from fluentD to SigNoz.
At SigNoz we use opentelemetry collector to recieve logs which supports the fluentforward protocol. So you can forward your logs from your fluentD agent to opentelemetry collector.
### Collect Logs Using FluentD in SigNoz cloud
- Add otel collector binary to your VM by following this [guide](https://signoz.io/docs/tutorial/opentelemetry-binary-usage-in-virtual-machine/).
- Add fluentforward reciever to your `config.yaml`
```yaml
receivers:
fluentforward:
endpoint: 0.0.0.0:24224
```
Here we have used port 24224 for listing in fluentforward protocol, but you can change it to a port you want.
You can read more about fluentforward receiver [here](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/fluentforwardreceiver).
- Modify your `config.yaml` and add the above receiver
```yaml {4}
service:
....
logs:
receivers: [otlp, fluentforward]
processors: [batch]
exporters: [otlp]
```
- Change the fluentD config to forward the logs to otel collector.
```
<source>
@type sample
sample [{"message": "my log data", "source": "myhost"}, {"message": "my log data 1", "source": "myhost1"}]
tag sample
rate 10000
</source>
<match sample>
@type forward
send_timeout 60s
recover_wait 10s
hard_timeout 60s
<server>
name myserver1
host otel-collector-host
port 24224
</server>
</match>
```
In this example we are generating sample logs and then forwarding them to the otel collector which is listening on port 24224.
`otel-collector-host` has to be replaced by the host where otel-collector is running. For more info check [troubleshooting](../install/troubleshooting.md#signoz-otel-collector-address-grid).
- Once you make this changes you can restart fluentD and otel-binary, and you will be able to see the logs in SigNoz.
- To properly transform your existing log model into opentelemetry [log](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md) model you can use the different processors provided by opentelemetry. [link](./logs.md#processors-available-for-processing-logs)
eg:-
```yaml
processors:
logstransform:
operators:
- type: trace_parser
trace_id:
parse_from: attributes.trace_id
span_id:
parse_from: attributes.span_id
- type: remove
field: attributes.trace_id
- type: remove
field: attributes.span_id
```
The operations in the above processor will parse the trace_id and span_id from log to opentelemetry log model and remove them from attributes.

View File

@ -0,0 +1,62 @@
If you use logstash to collect logs in your stack with this tutotrial you will be able to send logs from logstash to SigNoz.
At SigNoz we use opentelemetry collector to recieve logs which supports the TCP protocol. So you can forward your logs from your logstash agent to opentelemetry collector
## Steps to recieve logs from Logstash:
- Add fluentforward reciever to your `otel-collector-config.yaml` which is present inside `deploy/docker/clickhouse-setup`
```
receivers:
tcplog/logstash:
max_log_size: 1MiB
listen_address: "0.0.0.0:2255"
attributes: {}
resource: {}
add_attributes: false
operators: []
```
Here we have used port 2255 for listing in TCP protocol, but you can change it to a port you want.
You can read more about tcplog reciver [here](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/tcplogreceiver).
- Update the pipleline for logs and make the following change in `otel-collector-config.yaml`
```
service:
...
logs:
receivers: [ otlp, tcplog/logstash ]
processors: [ batch ]
exporters: [ clickhouselogsexporter ]
```
Here we are adding our clickhouse exporter and creating a pipeline which will collect logs from `tcplog/logstash` receiver, processing it using batch processor and export it to clickhouse.
- Expose the port in port for otel-collector in `docker-compose.yaml` file present in `deploy/docker/clickhouse-setup`
```
otel-collector:
...
ports:
- "2255:2255"
```
- Change the logstash config to forward the logs to otel collector.
```
output {
tcp {
codec => json_lines # this is required otherwise it will send eveything in a single line
host => "otel-collector-host"
port => 2255
}
}
```
In this example we are generating sample logs and then forwarding them to the otel collector which is listening on port 2255.
`otel-collector-host` has to be replaced by the host where otel-collector is running. For more info check [troubleshooting](../install/troubleshooting.md#signoz-otel-collector-address-grid).
- Once you make this changes you can restart logstash and SignNoz, and you will be able to see the logs in SigNoz.
- To properly transform your existing log model into opentelemetry [log](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md) model you can use the different processors provided by opentelemetry. [link](./logs.md#processors-available-for-processing-logs)

View File

@ -8,6 +8,7 @@ import { useState } from 'react';
import ApplicationLogs from './ApplicationLogs/ApplicationLogs'; import ApplicationLogs from './ApplicationLogs/ApplicationLogs';
import Docker from './Docker/Docker'; import Docker from './Docker/Docker';
import ExistingCollectors from './ExistingCollectors/ExistingCollectors';
import Kubernetes from './Kubernetes/Kubernetes'; import Kubernetes from './Kubernetes/Kubernetes';
import Nodejs from './Nodejs/Nodejs'; import Nodejs from './Nodejs/Nodejs';
import SysLogs from './SysLogs/SysLogs'; import SysLogs from './SysLogs/SysLogs';
@ -39,10 +40,15 @@ const supportedLogTypes = [
imgURL: `Logos/node-js.svg`, imgURL: `Logos/node-js.svg`,
}, },
{ {
name: 'Logs from existing Collectors', name: 'Application Logs using OTEL SDK',
id: 'application_logs_otel_sdk', id: 'application_logs_otel_sdk',
imgURL: `Logos/cmd-terminal.svg`, imgURL: `Logos/cmd-terminal.svg`,
}, },
{
name: 'Logs from existing collectors',
id: 'existing_collectors',
imgURL: `Logos/cmd-terminal.svg`,
},
]; ];
export default function LogsManagement({ export default function LogsManagement({
@ -70,6 +76,8 @@ export default function LogsManagement({
return <SysLogs activeStep={activeStep} />; return <SysLogs activeStep={activeStep} />;
case 'nodejs': case 'nodejs':
return <Nodejs activeStep={activeStep} />; return <Nodejs activeStep={activeStep} />;
case 'existing_collectors':
return <ExistingCollectors />;
default: default:
return <> </>; return <> </>;
} }