0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

MacOSからDatadog APMを送る (with Datadog Agent)

Posted at

概要

DatadogのTraceを、アプリのローカル実行で確認したいケースがある。
今回は、Mac上にDatadog Agentを立てて、Datadogにトレースを送るのを試す。

インストール

https://app.datadoghq.com/account/settings/agent/latest?platform=macos から Agentの設定をしていきます。

Screenshot 2024-10-26 at 9.10.02.png

DD_API_KEYを取得してから、以下のコマンドでインストールすることができます。

DD_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX DD_SITE="datadoghq.com" bash -c "$(curl -L https://install.datadoghq.com/scripts/install_mac_os.sh)"

起動

Screenshot 2024-10-26 at 9.06.16.png

メニューバーから起動、再起動、終了、WebUIを開くなど選択ができます。

設定

~/.datadog-agent/datadog.yamlまたはUI上から設定を変更できます。

Screenshot 2024-10-26 at 8.52.56.png

今回は試しにTraceの設定をEnableします。そして、Agentをリスタートします。

Application設定 (Golang)

package main

import (
	"net/http"

	httptrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/net/http"
	"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)

func main() {
	tracer.Start()
	defer tracer.Stop()
	mux := httptrace.NewServeMux(httptrace.WithServiceName("my-service"))
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("Hello World!\n"))
	})
	http.ListenAndServe(":8080", mux)
}
curl localhost:8080                
Hello World!

Datadog上で確認

Screenshot 2024-10-26 at 9.04.28.png

Screenshot 2024-10-26 at 9.04.43.png

Ref

  1. https://docs.datadoghq.com/tracing/guide/tutorial-enable-go-containers/
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?