Skip to content

Commit 974e9be

Browse files
Sonja Chèvresvrnmchalin
authored
Adds Tyk API Gateway blog post (open-telemetry#3431)
Co-authored-by: svrnm <[email protected]> Co-authored-by: Patrice Chalin <[email protected]>
1 parent 6507df0 commit 974e9be

File tree

4 files changed

+130
-0
lines changed

4 files changed

+130
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
---
2+
title: Tyk API Gateway's Native OpenTelemetry Integration
3+
linkTitle: Tyk API Gateway's Native OpenTelemetry Integration
4+
date: 2023-11-07
5+
author: >-
6+
[Sonja Chevre](https://github.com/SonjaChevre) (Tyk Technologies)
7+
---
8+
9+
{{< blog/integration-badge >}}
10+
11+
We're excited to announce that
12+
[Tyk API Gateway](https://github.com/TykTechnologies/tyk) has first-class
13+
support for OpenTelemetry, with native instrumentation built directly into the
14+
gateway. With Tyk's native OpenTelemetry support, developers and API platform
15+
teams get end-to-end observability into their API traffic, enabling faster
16+
troubleshooting and problem resolution.
17+
18+
## Why OpenTelemetry
19+
20+
API gateways, as the front-line proxies for APIs, play a crucial role in both
21+
the management and security of API traffic. A multitude of critical actions
22+
occur at the API gateway level. It is essential to monitor all requests,
23+
including those that never reach the upstream services because of rate-limiting
24+
rules, an authentication problem, or a caching mechanism. Collecting telemetry
25+
data at the API Gateway gives a clear entrance point and a complete picture of
26+
the journey of all the API consumers.
27+
28+
Before OpenTelemetry, Tyk Gateway already supported over 10 different formats
29+
for exporting metrics, logs, and traces. Maintaining this support demanded
30+
substantial engineering resources. OpenTelemetry streamlines this process,
31+
enabling a more efficient and standardized approach to collecting and exporting
32+
telemetry data. As a result, our users gain the flexibility to transmit their
33+
telemetry data to an even broader array of
34+
[observability tools and vendors](/ecosystem/vendors/).
35+
36+
We have now deprecated our support for OpenTracing in favor of OpenTelemetry for
37+
distributed tracing and plan to leverage OpenTelemetry to streamline the export
38+
of metrics and logs in the future.
39+
40+
## How to Integrate Tyk with OpenTelemetry
41+
42+
Starting with version 5.2,
43+
[Tyk API Gateway has native support for OpenTelemetry distributed tracing](https://tyk.io/docs/product-stack/tyk-gateway/advanced-configurations/distributed-tracing/open-telemetry/open-telemetry-overview/).
44+
Here is how to configure it, enable detailed tracing per API and instrumenting
45+
custom plugins.
46+
47+
### Enable OpenTelemetry at Gateway Level
48+
49+
Edit Tyk Gateway configuration file to enable OpenTelemetry support, like this:
50+
51+
```json
52+
{
53+
"opentelemetry": {
54+
"enabled": true
55+
}
56+
}
57+
```
58+
59+
You can also enable OpenTelemetry by setting the corresponding environment
60+
variable: `TYK_GW_OPENTELEMETRY_ENABLED=TRUE`.
61+
62+
By default, OpenTelemetry spans are exported using the gRPC protocol to
63+
`localhost:4317`. For more configuration options and default values, refer to
64+
the
65+
[documentation](https://tyk.io/docs/tyk-oss-gateway/configuration/#opentelemetry).
66+
67+
Tyk will export two spans: one for the total duration of the API call and one
68+
span for the call to the upstream service, as shown in the following screenshot
69+
from Jaeger.
70+
71+
![Typ API Gateway distributed trace](tyk-api-gateway-opentelemetry-trace.png)
72+
73+
### Detailed tracing per APIs
74+
75+
Upon enabling OpenTelemetry at the gateway level, you gain the flexibility to
76+
activate detailed tracing for particular APIs. To do so, simply adjust the
77+
corresponding API definition and toggle the `detailed_tracing` option to either
78+
`true` or `false`. The default value for this setting is `false`. With this
79+
configuration, Tyk will generate a span for every middleware operation carried
80+
out throughout the API request/response lifecycle. This includes actions like
81+
API version validation, authentication, authorization, rate limiting, and
82+
request and response transformation.
83+
84+
Here you can quickly spot an issue reported by the rate limiting middleware:
85+
86+
![Typ API Gateway distributed trace with middleware details](tyk-api-gateway-opentelemetry-trace-detail.png)
87+
88+
### Instrumenting custom plugins with OpenTelemetry
89+
90+
Tyk supports the use of custom plugins (also called custom middleware) to extend
91+
its functionality, making it a highly flexible and customizable API gateway
92+
solution. This extensibility allows developers to tailor Tyk to their specific
93+
needs, whether it's for enhancing security, adding new authentication methods,
94+
integrating with third-party services, or implementing custom request/response
95+
transformations.
96+
97+
By instrumenting custom plugins with OpenTelemetry SDK or Tyk’s OpenTelemetry
98+
library implementation (wrapper of the OpenTelemetry SDK that all Tyk components
99+
are sharing for convenience), Tyk users can gain additional insights into their
100+
custom plugin behavior for better monitoring and quicker troubleshooting. More
101+
information in Tyk’s documentation:
102+
[OpenTelemetry Instrumentation in Go Plugins](https://tyk.io/docs/product-stack/tyk-gateway/advanced-configurations/plugins/otel-plugins/).
103+
104+
## What's next?
105+
106+
Now that the
107+
[first stable release of OTel Go metric SDK has been announced](/blog/2023/otel-go-metrics-sdk-stable/),
108+
we will be investigating support for OpenTelemetry metrics. Stay tuned for
109+
updates and don't hesitate to
110+
[reach out on Tyk's community with any feedback](https://community.tyk.io/).
Loading
Loading

static/refcache.json

+20
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,10 @@
455455
"StatusCode": 200,
456456
"LastSeen": "2023-07-03T17:44:06.5954165Z"
457457
},
458+
"https://community.tyk.io/": {
459+
"StatusCode": 200,
460+
"LastSeen": "2023-10-26T12:18:59.472082+02:00"
461+
},
458462
"https://communityinviter.com/apps/cloud-native/cncf": {
459463
"StatusCode": 200,
460464
"LastSeen": "2023-06-29T15:55:08.258786-04:00"
@@ -1915,6 +1919,14 @@
19151919
"StatusCode": 200,
19161920
"LastSeen": "2023-06-30T09:43:05.833301-04:00"
19171921
},
1922+
"https://github.com/SonjaChevre": {
1923+
"StatusCode": 200,
1924+
"LastSeen": "2023-10-26T12:18:57.59078+02:00"
1925+
},
1926+
"https://github.com/TykTechnologies/tyk": {
1927+
"StatusCode": 200,
1928+
"LastSeen": "2023-10-26T12:18:58.23681+02:00"
1929+
},
19181930
"https://github.com/Workiva/opentelemetry-dart": {
19191931
"StatusCode": 200,
19201932
"LastSeen": "2023-06-30T08:34:38.397928-04:00"
@@ -5403,6 +5415,14 @@
54035415
"StatusCode": 206,
54045416
"LastSeen": "2023-09-19T18:15:55.842511+02:00"
54055417
},
5418+
"https://tyk.io/docs/product-stack/tyk-gateway/advanced-configurations/plugins/otel-plugins/": {
5419+
"StatusCode": 206,
5420+
"LastSeen": "2023-10-26T12:18:59.024513+02:00"
5421+
},
5422+
"https://tyk.io/docs/tyk-oss-gateway/configuration/#opentelemetry": {
5423+
"StatusCode": 206,
5424+
"LastSeen": "2023-10-26T12:18:58.666794+02:00"
5425+
},
54065426
"https://ucum.org/ucum.html#para-curly": {
54075427
"StatusCode": 200,
54085428
"LastSeen": "2023-06-29T18:39:26.73908-04:00"

0 commit comments

Comments
 (0)