krakend / krakend-ce

KrakenD Community Edition: High-performance, stateless, declarative, API Gateway written in Go.
https://www.krakend.io
Apache License 2.0
1.99k stars 453 forks source link

Configure Distributed Tracing With APM Server #536

Closed ReginaldoSantos closed 1 year ago

ReginaldoSantos commented 2 years ago

Environment info: devopsfaith/krakend:2.0.4 successfully deployed with flexible configuration.

Describe what are you trying to do: I have distributed tracing for http requests configured with Elastic APM server (and EFK stack). Thus, BFF in NodeJS, Spring Cloud Gateway and Microservices in Java/Spring are all instrumented with elastic apm agents.

However, we are moving now to KrakenD (replacing Spring Cloud Gateway) and I'm wondering if there is some way to keep using the very same tracing stack.

Is this somehow possible? Could any of the exporters send trace information to APM Server out of the box so it can be visualized in Kibana's APM view?

Your configuration file: krakend.json snippet

{
    "$schema": "https://www.krakend.io/schema/v3.json",
    "version": 3,
    "name": "API Gateway",
    "timeout": "10000ms",
    "cache_ttl": "300s",
    "output_encoding": "no-op",
    "sequential_start": true,
    "extra_config":
    {
        "telemetry/logging":
        {
            "level": "DEBUG",
            "prefix": "[KRAKEND]",
            "syslog": false,
            "stdout": true,
            "format": "logstash"
        }
    },
    "endpoints":
    [
        {
            "endpoint": "/admin/tenants",
            "method": "GET",
            "extra_config":
            {
                "auth/validator":
                {
                    "alg": "RS256",
                    "jwk_url": "http://ms-jwks.backoffice/.well-known/jwks.json",
                    "disable_jwk_security": true,
                    "cache": true,
                    "roles_key_is_nested": true,
                    "roles_key": "resource_access.admin.roles",
                    "roles":
                    [
                        "Admin"
                    ],
                    "scopes_key": "scope",
                    "scopes":
                    [
                        "profile"
                    ],
                    "scopes_matcher": "any",
                    "propagate_claims":
                    [
                        [
                            "realm",
                            "X-TenantId"
                        ]
                    ],
                    "operation_debug": true
                }
            },
            "output_encoding": "no-op",
            "input_headers":
            [
                "*"
            ],
            "input_query_strings":
            [
                "*"
            ],
            "backend":
            [
                {
                    "url_pattern": "/tenants",
                    "method": "GET",
                    "encoding": "no-op",
                    "sd": "static",
                    "disable_host_sanitize": true,
                    "host":
                    [
                        "http://ms-admin.backoffice"
                    ]
                }
            ]
        }
    ]
}

Additional comments:

For example, as both jaeger and apm support OTel, would jaeger exporter work?

        "telemetry/opencensus": {
            "sample_rate": 100,
            "reporting_period": 1,
            "exporters": {
                "jaeger": {
                    "endpoint": "http://apm-server.monitoring:8200",
                    "service_name":"krakend",
                    "buffer_max_count": 1000
                }
            }
        }

If not, is there another way? (maybe setting some communication between jaeger and apm-server?)

alombarte commented 2 years ago

I personally do not have any experience with APM Server, but the Jaeger exporter uses Opencensus instead of OpenTelemetry.

Let us know if you managed to integrate it.

ReginaldoSantos commented 2 years ago

We did shift to KrakenD successfully, however, there's still this open gap!

As soon as I have time to get back into this I will give it a try and let you know. Tks.

github-actions[bot] commented 1 year ago

This issue is marked as stale because it has been open over 90 days with no activity. Remove the stale label or comment or this will be closed in 15 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been marked as stalled for 15 days with no activity.

github-actions[bot] commented 1 year ago

This issue was marked as resolved a long time ago and now has been automatically locked as there has not been any recent activity after it. You can still open a new issue and reference this link.