-
Notifications
You must be signed in to change notification settings - Fork 991
dnsdist: Add feature to create Telemetry Spans from LuaAction #16961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pieterlexis
wants to merge
17
commits into
PowerDNS:master
Choose a base branch
from
pieterlexis:dnsdist-lua-opentelemetry
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
18f4098
fix(dnsdist): Add TraceID to minimal PDNS Protobuf
pieterlexis 4899b47
feat(dnsdist): Add Trace spans from Lua
pieterlexis d294ab9
docs(dnsdist): Add docs on Trace Spans from Lua
pieterlexis ff5d4ec
feat(dnsdist): simplify DNSQuestion:withTraceSpan
pieterlexis 900af92
docs(dnsdist): Update docs for OT Tracing from Lua
pieterlexis d6a182a
feat: add `defer` and `deferFunc`
pieterlexis 86dba4b
feat(dnsdist): make withTraceSpan available globally
pieterlexis 6cf017a
docs(dnsdist): Update docs with the new Trace infra
pieterlexis dfdc42c
feat(pb): Add an "Internal" message type
pieterlexis bc13e00
feat(dnsdist): Allow setting the OT Trace scope name
pieterlexis b502871
feat(dnsdist): Allow setting the OT Trace Span Kind
pieterlexis 0ed7c71
feat(dnsdist): Trace the maintenance function
pieterlexis 9363c79
feat(dnsdist): Add Lua config for internal traces
pieterlexis 4d8db67
feat(dnsdist): Add internal OT traces test
pieterlexis 43b2871
feat(dnsdist): Add Lua Span function for maintenance
pieterlexis 2b0ef5b
docs(dnsdist): Add maintenance OT Lua docs
pieterlexis e0ce128
docs(dnsdist): add Lua config for OT Trace
pieterlexis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* | ||
| * This file is part of PowerDNS or dnsdist. | ||
| * Copyright -- PowerDNS.COM B.V. and its contributors | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of version 2 of the GNU General Public License as | ||
| * published by the Free Software Foundation. | ||
| * | ||
| * In addition, for the avoidance of any doubt, permission is granted to | ||
| * link this program with OpenSSL and to (re)distribute the binaries | ||
| * produced as the result of such linking. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| */ | ||
|
|
||
| #include "dnsdist-lua-bindings-opentelemetry.hh" | ||
|
|
||
| namespace pdns::trace::dnsdist | ||
| { | ||
| void emptyLuaTracing(LuaContext& luaCtx) | ||
| { | ||
| luaCtx.writeFunction<void(const std::string&, const std::function<void()>&)>( | ||
| "withTraceSpan", | ||
| []([[maybe_unused]] const std::string& name, const std::function<void()>& luaFunc) { | ||
| luaFunc(); | ||
| }); | ||
|
|
||
| luaCtx.writeFunction<void(const std::string&, const std::string&)>( | ||
| "setSpanAttribute", | ||
| []([[maybe_unused]] const std::string& key, [[maybe_unused]] const std::string& value) { | ||
| return; | ||
| }); | ||
| }; | ||
|
|
||
| void setupLuaTracing(LuaContext& luaCtx, std::shared_ptr<Tracer>& tracer) | ||
| { | ||
| if (tracer != nullptr) { | ||
| luaCtx.writeFunction<void(const std::string&, const std::function<void()>&)>( | ||
| "withTraceSpan", | ||
| [&tracer](const std::string& name, const std::function<void()>& luaFunc) { | ||
| #ifndef DISABLE_PROTOBUF | ||
| if (tracer != nullptr) { | ||
| auto closer = tracer->openSpan(name); | ||
| luaFunc(); | ||
| return; | ||
| } | ||
| #endif | ||
| luaFunc(); | ||
| }); | ||
|
|
||
| luaCtx.writeFunction<void(const std::string&, const std::string&)>( | ||
| "setSpanAttribute", | ||
| [&tracer](const std::string& key, const std::string& value) { | ||
| #ifndef DISABLE_PROTOBUF | ||
| if (tracer != nullptr) { | ||
| tracer->setSpanAttribute(tracer->getLastSpanID(), key, AnyValue{value}); | ||
| } | ||
| #endif | ||
| return; | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| } // namespace pdns::trace::dnsdist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * This file is part of PowerDNS or dnsdist. | ||
| * Copyright -- PowerDNS.COM B.V. and its contributors | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of version 2 of the GNU General Public License as | ||
| * published by the Free Software Foundation. | ||
| * | ||
| * In addition, for the avoidance of any doubt, permission is granted to | ||
| * link this program with OpenSSL and to (re)distribute the binaries | ||
| * produced as the result of such linking. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "ext/luawrapper/include/LuaContext.hpp" | ||
|
|
||
| #include "dnsdist-lua.hh" | ||
| #include "dnsdist-opentelemetry.hh" | ||
| #include "lock.hh" | ||
| #include "misc.hh" | ||
|
|
||
| namespace pdns::trace::dnsdist | ||
| { | ||
| void emptyLuaTracing(LuaContext&); | ||
| void setupLuaTracing(LuaContext&, std::shared_ptr<Tracer>&); | ||
|
|
||
| template <typename Func, typename... Args> | ||
| auto runWithLuaTracing(LuaContext& luaCtx, std::shared_ptr<Tracer>& tracer, Func&& func, Args&&... args) | ||
|
||
| { | ||
| setupLuaTracing(luaCtx, tracer); | ||
| auto exitGuard = ::pdns::defer([&luaCtx] { | ||
| emptyLuaTracing(luaCtx); | ||
| }); | ||
| return std::invoke(std::forward<Func>(func), std::forward<Args>(args)...); | ||
| } | ||
|
|
||
| template <typename Func, typename... Args> | ||
| auto runWithLuaTracing(std::shared_ptr<Tracer>& tracer, Func&& func, Args&&... args) | ||
| { | ||
| auto luaCtx = g_lua.lock(); | ||
| return runWithLuaTracing(*luaCtx, tracer, func, args...); | ||
| } | ||
|
|
||
| } // namespace pdns::trace::dnsdist | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.