๋ด๋ ๋ฆญ์ .NET ์์ด์ ํธ์๋ ์์ด์ ํธ์ ํ์ค ๊ธฐ๋ฅ์ ํ์ฅํ ์ ์๋ API ํฌํจ๋์ด ์์ต๋๋ค. ์๋ฅผ ๋ค์ด .NET ์์ด์ ํธ API๋ฅผ ์ฌ์ฉํ์ฌ ๋ค์์ ์ํํ ์ ์์ต๋๋ค.
- ์ฑ ์ด๋ฆ ๋ง์ถค์ค์
- ์ฌ์ฉ์ ์ ์ ํธ๋์ญ์ ๋งค๊ฐ๋ณ์ ์์ฑ
- ๋ง์ถค ์ค๋ฅ ๋ฐ ์ธก์ ํญ๋ชฉ ๋ณด๊ณ
๊ตฌ์ฑ ์ค์ ์ ์กฐ์ ํ๊ฑฐ๋ ์ฌ์ฉ์ ์ง์ ๊ณ์ธก ์ ์ฌ์ฉํ์ฌ .NET ์์ด์ ํธ์ ์ผ๋ถ ๊ธฐ๋ณธ ๋์์ ์ฌ์ฉ์ ์ง์ ํ ์๋ ์์ต๋๋ค.
์๊ตฌ ์ฌํญ
.NET ์์ด์ ํธ API๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ์ต์ .NET ์์ด์ ํธ ๋ฆด๋ฆฌ์ค๊ฐ ์๋์ง ํ์ธํ์ธ์. ๊ทธ๋ฐ ๋ค์ ์๋ ๋ ๊ฐ์ง ์ต์ ์ค ํ๋๋ฅผ ์ฌ์ฉํ์ฌ ํ๋ก์ ํธ์ ์์ด์ ํธ์ ๋ํ ์ฐธ์กฐ๋ฅผ ์ถ๊ฐํ์ธ์.
ํ๋ก์ ํธ์
NewRelic.Api.Agent.dll์ ๋ํ ์ฐธ์กฐ๋ฅผ ์ถ๊ฐํฉ๋๋ค.๋๋
NuGet ํจํค์ง ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์์ API ํจํค์ง๋ฅผ ๋ณด๊ณ ๋ค์ด๋ก๋ํฉ๋๋ค.
API ํธ์ถ ๋ชฉ๋ก
๋ค์ ๋ชฉ๋ก์๋ ๊ตฌ๋ฌธ, ์๊ตฌ ์ฌํญ, ๊ธฐ๋ฅ ๋ฐ ์๋ฅผ ํฌํจํ์ฌ API๋ฅผ ์ฌ์ฉํ์ฌ ์ํํ ์ ์๋ ๋ค์ํ ํธ์ถ์ด ํฌํจ๋์ด ์์ต๋๋ค.
ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.DisableBrowserMonitoring([boolean $override])ํน์ ํ์ด์ง์์ ๋ธ๋ผ์ฐ์ ๋ชจ๋ํฐ๋ง ์ค๋ํซ์ ์๋ ์ฝ์ ์ ๋นํ์ฑํํฉ๋๋ค.
์๊ตฌ ์ฌํญ
- ๋ชจ๋ ์์ด์ ํธ ๋ฒ์ ๊ณผ ํธํ๋ฉ๋๋ค.
- ํธ๋์ญ์ ๋ด์์ ํธ์ถ๋์ด์ผ ํฉ๋๋ค.
์ค๋ช
ํน์ ํ์ด์ง์์ ํผ์ณ๋ณด๊ธฐ์ ์๋ ๋ด์ฉ์ ๋นํ์ฑํํ๋ ค๋ฉด ์ด ํธ์ถ์ ์ถ๊ฐํ์ธ์. ์ ํ์ ์ฌ์ ์๋ฅผ ์ถ๊ฐํ์ฌ ์๋ ๋ฐ ์๋ ์ฃผ์ ์ ๋ชจ๋ ๋นํ์ฑํํ ์๋ ์์ต๋๋ค. ๋ ๊ฒฝ์ฐ ๋ชจ๋ ์ด API ํธ์ถ์ ๋ธ๋ผ์ฐ์ ๋ฅผ ๋นํ์ฑํํ๋ ค๋ ๋ณด๊ธฐ์ ์๋จ์ ์ต๋ํ ๊ฐ๊น๊ฒ ๋ฐฐ์นํ์ธ์.
ํ
ํ์ด์ง์ ๋ธ๋ผ์ฐ์ ์คํฌ๋ฆฝํธ๋ฅผ GetBrowserTimingHeader() ****์ถ๊ฐํ๋ ๋น๊ตํ์ธ์.
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ถ์ธ | ์ ํ ๊ณผ๋ชฉ. |
์
์๋ ์ฃผ์ ๋นํ์ฑํ
์ด ์์์๋ ์ค๋ํซ์ ์๋ ์ฝ์ ๋ง ๋นํ์ฑํํฉ๋๋ค.
NewRelic.Api.Agent.NewRelic.DisableBrowserMonitoring();์๋ ๋ฐ ์๋ ์ฃผ์ ๋นํ์ฑํ
์ด ์์์๋ ์ค๋ํซ์ ์๋ ๋ฐ ์๋ ์ฝ์ ์ ๋ชจ๋ ๋นํ์ฑํํฉ๋๋ค.
NewRelic.Api.Agent.NewRelic.DisableBrowserMonitoring(true);ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.GetAgent()IAgent ์ธํฐํ์ด์ค๋ฅผ ํตํด ์์ด์ ํธ์ ์ก์ธ์คํฉ๋๋ค.
์๊ตฌ ์ฌํญ
- ์์ด์ ํธ ๋ฒ์ 8.9 ์ด์.
- ๋ชจ๋ ์ฑ ์ ํ๊ณผ ํธํ๋ฉ๋๋ค.
์ค๋ช
IAgent ์ธํฐํ์ด์ค๋ฅผ ํตํด ์์ด์ ํธ API ๋ฉ์๋์ ์ก์ธ์คํ์ธ์.
๋ฐํ ๊ฐ
IAgent API์ ๋ํ ์ก์ธ์ค๋ฅผ ์ ๊ณตํ๋ IAgent ๊ตฌํ์ ๋๋ค.
์
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent();ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.GetBrowserTimingHeader();NewRelic.Api.Agent.NewRelic.GetBrowserTimingHeader(string nonce);์ต์ข ์ฌ์ฉ์ ๋ธ๋ผ์ฐ์ ๋ฅผ ๊ณ์ธกํ๊ธฐ ์ํด ๋ธ๋ผ์ฐ์ ๋ชจ๋ํฐ๋ง HTML ์ค๋ํซ์ ์์ฑํฉ๋๋ค.
์๊ตฌ ์ฌํญ
- ๋ชจ๋ ์์ด์ ํธ ๋ฒ์ ๊ณผ ํธํ๋ฉ๋๋ค.
- ํธ๋์ญ์ ๋ด์์ ํธ์ถ๋์ด์ผ ํฉ๋๋ค.
์ค๋ช
ํ์ฑํํ๋ ๋ฐ ์ฌ์ฉ๋๋ HTML ์ค๋ํซ์ ๋ฐํํฉ๋๋ค. ์ค๋ํซ์ ๋ธ๋ผ์ฐ์ ์ ์์ JavaScript ํ์ผ์ ๊ฐ์ ธ์ค๊ณ ํ์ด์ง ํ์ด๋จธ๋ฅผ ์์ํ๋๋ก ์ง์ํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ ๋ฐํ๋ ์ค๋ํซ์ HTML ์นํ์ด์ง ํค๋์ ์ฝ์ ํ ์ ์์ต๋๋ค. ์์ธํ ๋ด์ฉ์ ๋ธ๋ผ์ฐ์ ๋ชจ๋ํฐ๋ง์ ์ฑ ์ถ๊ฐ๋ฅผ ์ฐธ์กฐํ์ธ์.
ํ
ํ์ด์ง์์ ๋ธ๋ผ์ฐ์ ์คํฌ๋ฆฝํธ๋ฅผ ๋นํ์ฑํ ํ๋ DisableBrowserMonitoring() ๋น๊ตํด ๋ณด์ธ์.
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ | ์ฝํ ์ธ ๋ณด์ ์ ์ฑ ์ ์ฑ ์์ ์ฌ์ฉํ๋ ์์ฒญ๋ณ ์ํธํ ์์๊ฐ์ ๋๋ค. |
ํ
์ด API ํธ์ถ์๋ ๋ณด์ ํ์ฉ ๋ชฉ๋ก์ ๋ํ ์ ๋ฐ์ดํธ๊ฐ ํ์ํฉ๋๋ค. CSP(์ฝํ ์ธ ๋ณด์ ์ ์ฑ ) ๊ณ ๋ ค ์ฌํญ์ ๋ํ ์์ธํ ๋ด์ฉ์ ๋ธ๋ผ์ฐ์ ๋ชจ๋ํฐ๋ง ํธํ์ฑ ๋ฐ ์๊ตฌ ์ฌํญ ํ์ด์ง๋ฅผ ์ฐธ์กฐํ์ธ์.
๋ฐํ ๊ฐ
ํ์ด์ง ํค๋์ ํฌํจํ HTML ๋ฌธ์์ด์ ๋๋ค.
์
<html><head> <%= NewRelic.Api.Agent.NewRelic.GetBrowserTimingHeader()%> ...</head><body>...<html><head> <%= NewRelic.Api.Agent.NewRelic.GetBrowserTimingHeader("YOUR_NONCE_VALUE")%> ...</head><body>...<!DOCTYPE html><html lang="en"><head> @Html.Raw(NewRelic.Api.Agent.NewRelic.GetBrowserTimingHeader()) ...</head><body>...<!DOCTYPE html><html lang="en"><head> @Html.Raw(NewRelic.Api.Agent.NewRelic.GetBrowserTimingHeader("YOUR_NONCE_VALUE")) ...</head><body>...์ค์
์์ด์ ํธ๊ฐ ์น ์ด์ ๋ธ๋ฆฌ ์ฝ๋๋ฅผ ๊ณ์ธกํ ์ ์๊ธฐ ๋๋ฌธ์ Blazor ์น ์ด์ ๋ธ๋ฆฌ์๋ ์ด API๊ฐ ์ง์๋์ง ์์ต๋๋ค. ๋ค์ ์์ ๋ Blazor Server ์ ํ๋ฆฌ์ผ์ด์ ์๋ง ํด๋น๋ฉ๋๋ค. Blazor ์น ์ด์ ๋ธ๋ฆฌ ํ์ด์ง์ ๋ธ๋ผ์ฐ์ ์์ด์ ํธ๋ฅผ ์ถ๊ฐํ๋ ค๋ฉด ๋ณต์ฌ-๋ถ์ฌ๋ฃ๊ธฐ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ์ธ์.
์ค์
์ด API๋ .razor ํ์ด์ง์ <HeadContent> ์์์ ๋ฐฐ์นํ ์ ์์ต๋๋ค. ๋์ _Layout.cshtml ๋๋ ์ด์ ์์ํ๋ ๋ ์ด์์ ํ์ผ์์ ํธ์ถํด์ผ ํฉ๋๋ค.
<!DOCTYPE html><html lang="en"><head> @Html.Raw(NewRelic.Api.Agent.NewRelic.GetBrowserTimingHeader()) ...</head><body>...<!DOCTYPE html><html lang="en"><head> @Html.Raw(NewRelic.Api.Agent.NewRelic.GetBrowserTimingHeader("YOUR_NONCE_VALUE")) ...</head><body>...ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.GetLinkingMetadata();์ถ์ ๋๋ ์ํฐํฐ๋ฅผ ์ฐ๊ฒฐํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋ ํค/๊ฐ ์์ ๋ฐํํฉ๋๋ค.
์๊ตฌ ์ฌํญ
- ์์ด์ ํธ ๋ฒ์ 8.19 ์ด์.
- ๋ชจ๋ ์ฑ ์ ํ๊ณผ ํธํ๋ฉ๋๋ค.
์ค๋ช
๋ฐํ๋ ํค/๊ฐ ์์ ์ฌ์ ์๋ APM ์ ํ์์ ํธ๋ ์ด์ค์ ์ํฐํฐ๋ฅผ ์ฐ๊ฒฐํ๋ ๋ฐ ์ฌ์ฉ๋๋ ํญ๋ชฉ์ด ํฌํจ๋์ด ์์ต๋๋ค. ์๋ฏธ ์๋ ๊ฐ์ ๊ฐ์ง ํญ๋ชฉ๋ง ํฌํจ๋ฉ๋๋ค. ๋๋ฌธ์, ์ ์ธ ์ถ์ ์ด ๋นํ์ฑํ๋ ๊ฒฝ์ฐ trace.id (๋) ํฌํจ๋์ง ์์ต๋๋ค.
๋ฐํ ๊ฐ
Dictionary <string, string>() ๋ฐํ๋ ํญ๋ชฉ์๋ APM ์ ํ์ ์ถ์ ๋ฐ ์ํฐํฐ๋ฅผ ์ฐ๊ฒฐํ๋ ๋ฐ ์ฌ์ฉ๋๋ ํญ๋ชฉ์ด ํฌํจ๋ฉ๋๋ค.
์
NewRelic.Api.Agent.IAgent Agent = NewRelic.Api.Agent.NewRelic.GetAgent();var linkingMetadata = Agent.GetLinkingMetadata();foreach (KeyValuePair<string, string> kvp in linkingMetadata){ Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);}ํต์ฌ๋ก
public interface IAgentํ์ฌ ์คํ ์ค์ธ ํธ๋์ญ์ ๊ณผ ๊ฐ์ ์์ด์ ํธ ์ํฐํฉํธ ๋ฐ ๋ฉ์๋์ ๋ํ ์ก์ธ์ค๋ฅผ ์ ๊ณตํฉ๋๋ค.
์๊ตฌ ์ฌํญ
- ์์ด์ ํธ ๋ฒ์ 8.9 ์ด์.
- ๋ชจ๋ ์ฑ ์ ํ๊ณผ ํธํ๋ฉ๋๋ค.
์ค๋ช
ํ์ฌ ์คํ ์ค์ธ ํธ๋์ญ์
๊ณผ ๊ฐ์ ์์ด์ ํธ ์ํฐํฉํธ ๋ฐ ๋ฉ์๋์ ๋ํ ์ก์ธ์ค๋ฅผ ์ ๊ณตํฉ๋๋ค. IAgent ์ ๋ํ ์ฐธ์กฐ๋ฅผ ์ป์ผ๋ ค๋ฉด GetAgent ์ฌ์ฉํ์ญ์์ค.
์์ฑ
์ด๋ฆ | ์ค๋ช |
|---|---|
ํ์ฌ ํธ๋์ญ์ | ITransaction ์ธํฐํ์ด์ค๋ฅผ ํตํด ํ์ฌ ์คํ ์ค์ธ ํธ๋์ญ์ ์ ๋ํ ์ก์ธ์ค๋ฅผ ์ ๊ณตํ๋ ์์ฑ์ ๋๋ค. ํธ๋์ญ์ ๋ด์์ ํธ์ถ๋์ด์ผ ํฉ๋๋ค. |
ํ์ฌ ๋ฒ์ | ISpan ์ธํฐํ์ด์ค๋ฅผ ํตํด ํ์ฌ ์คํ ์ค์ธ ๋ฒ์์ ๋ํ ์ก์ธ์ค๋ฅผ ์ ๊ณตํ๋ ์์ฑ์ ๋๋ค. |
์
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent();ITransaction transaction = agent.CurrentTransaction;ํต์ฌ๋ก
public interface ITransactionNew Relic API์ ํธ๋์ญ์ ๋ณ ๋ฉ์๋์ ๋ํ ์ก์ธ์ค๋ฅผ ์ ๊ณตํฉ๋๋ค.
์ค๋ช
๋ด๋ ๋ฆญ .NET ์์ด์ ํธ API ์ ํ๋ก์ธ์ ๊ด๋ จ ๋ฉ์๋์ ๋ํ ์ก์ธ์ค๋ฅผ ์ ๊ณตํฉ๋๋ค. ITransaction ์ ๋ํ ์ฐธ์กฐ๋ฅผ ์ป์ผ๋ ค๋ฉด IAgent ์์ ์ฌ์ฉ ๊ฐ๋ฅํ ํ์ฌ ํธ๋์ญ์
๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ธ์.
๋ค์ ๋ฐฉ๋ฒ์ ITransaction์์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
์ด๋ฆ | ์ค๋ช |
|---|---|
| ๋๊ฐ๋ ์์ฒญ์ ๋ถ์ฐ ์ถ์ ๋ฐ์ดํฐ๋ฅผ ์ถ๊ฐํฉ๋๋ค(์์ธํ ๋ด์ฉ์ ์๋ ์ฐธ์กฐ). |
| ๋ค๋ฅธ ์๋น์ค์์ ๋ค์ด์ค๋ ๋ถ์ฐ ์ถ์ ๋ฐ์ดํฐ๋ฅผ ์๋ฝํฉ๋๋ค(์์ธํ ๋ด์ฉ์ ์๋ ์ฐธ์กฐ). |
| ์์ฑ์ ํ์์ผ๋ก ๊ทํ์ ์์ผ์ ์ํฉ๋ณ ์ ๋ณด๋ฅผ ํ์ฌ ์๋์ ์ถ๊ฐํฉ๋๋ค(์์ธํ ๋ด์ฉ์ ์๋ ์ฐธ์กฐ). |
| ํ์ฌ ์คํ ์ค์ธ span ์ ๋ํ ์ก์ธ์ค๋ฅผ ์ ๊ณตํ๋ฉฐ, ์ด๋ฅผ ํตํด ๋ด๋ ๋ฆญ API ์ span ๊ด๋ จ ๋ฉ์๋์ ์ก์ธ์คํ ์ ์์ต๋๋ค(์์ธํ ๋ด์ฉ์ ์๋ ์ฐธ์กฐ). |
| ์ฌ์ฉ์ ID๋ฅผ ํ์ฌ ์๋์ ์ฐ๊ฒฐํฉ๋๋ค(์์ธํ ๋ด์ฉ์ ์๋ ์ฐธ์กฐ). |
| ์ง์๋์ง ์๋ ๋ฐ์ดํฐ์คํ ์ด๋ฅผ ์ฌ์ดํธํํ ์ ์๋๋ก ํ์ฉํฉ๋๋ค(์์ธํ ๋ด์ฉ์ ์๋ ์ฐธ์กฐ). |
ํต์ฌ๋ก
void InsertDistributedTraceHeaders(carrier, setter)๋ค๋ฅธ ์์ ๋ ์๋น์ค์ ๋ํ ์์๋ฐ์ด๋ ๋ฉ์์ง์ ์ ์ธ๋ ์ถ์ ๋ฐ์ดํฐ๋ฅผ ์ถ๊ฐํฉ๋๋ค.
์ค๋ช
ITransaction.InsertDistributedTraceHeaders W3C Trace Context ํค๋์ ๋ด๋ ๋ฆญ ํตํฉ ํธ๋ ์ด์ค ํค๋๋ฅผ ์ถ๊ฐํ์ฌ ์ ๋ฌ๋ ์บ๋ฆฌ์ด ๊ฐ์ฒด๋ฅผ ์์ ํฉ๋๋ค. ๋ด๋ ๋ฆญ ํค๋๋ config์์ <distributedTracing excludeNewrelicHeader="true" /> ์ฌ์ฉํ์ฌ ๋นํ์ฑํํ ์ ์์ต๋๋ค.
๋งค๊ฐ๋ณ์
์ด๋ฆ | ์ค๋ช |
|---|---|
<ํฐ> | ํ์์. ๋ถ์ฐ ์ถ์ ๋ฐ์ดํฐ๊ฐ ์ฝ์
๋๋ ํค/๊ฐ ์ ์ ์ฅ์์
๋๋ค. ์ด๊ฒ์ ํธ์ถ ์๋น์ค์์ ํธ์ถ๋๋ ์๋น์ค๋ก ์ ๋ฌ๋๋ ๋ชจ๋ ๋ฉ์์ง ๊ฐ์ฒด์ ์กด์ฌํด์ผ ํ๋ฉฐ, ์ฌ์ฉ๋๋ ์ ์ก ์๋จ์ ๋ฐ๋ผ ๋ฌ๋ผ์ผ ํฉ๋๋ค. ์๋ฅผ ๋ค์ด Azure Service Bus ๋ฉ์์ง์ ๊ฒฝ์ฐ |
์ก์ <T, ๋ฌธ์์ด, ๋ฌธ์์ด> | ํ์์. ์ถ์ ๋ฐ์ดํฐ๋ฅผ ํต์ ์ฌ์ ์ฝ์ ํ๊ธฐ ์ํ ์ฌ์ฉ์ ์ ์ ์์ ์ ๋๋ค. ์๋์ ์๋ฅผ ๋ณด์ธ์. |
์ฌ์ฉ ๊ณ ๋ ค ์ฌํญ
- ๋ถ์ฐ ์ถ์ ์ ํ์ฑํํด์ผ ํฉ๋๋ค .
- ์ด API ๊ธฐ์กด ๋ผ์ด์ผ์ค ์ปจํ ์คํธ ๋ด์์๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค.
์์
์ด API์ ์ฌ์ฉ๋ฒ์ ๋ณด์ฌ์ฃผ๊ธฐ ์ํด ๋น๋ํ๊ณ ์คํํ ์ ์๋ ์ ์ฒด ์์ ๋ ์ฌ๊ธฐ์์ ์ฐพ์ ์ ์์ต๋๋ค.
// Get a reference to the agent, which lets you get a reference to the current transactionIAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent();ITransaction currentTransaction = agent.CurrentTransaction;
// In this example, we are using Azure Service Bus. The `ServiceBusMessage` type has an `ApplicationProperties` property for custom key/value pairs.
// Create the outbound messageServiceBusMessage message = new ("Hello, world!");
// Define the setter Action. The `ApplicationProperties` dictionary is the trace data carrier.var setter = new Action<ServiceBusMessage, string, string>((carrier, key, value) => { carrier.ApplicationProperties?.Set(key, value); });
// Call the API to add the distributed tracing data to the messagecurrentTransaction.InsertDistributedTraceHeaders(message, setter);
// Send the messageํต์ฌ๋ก
void AcceptDistributedTraceHeaders(carrier, getter, transportType)๋ค๋ฅธ ์์ ๋ ์๋น์ค์ ์ธ๋ฐ์ด๋ ๋ฉ์์ง์์ ์ถ์ถ๋ ๋ฐ์ดํฐ๋ฅผ ์๋ฝํฉ๋๋ค.
์ค๋ช
ITransaction.AcceptDistributedTraceHeaders InsertDistributedTraceHeaders ๋๋ ๋ค๋ฅธ W3C Trace Context ํธํ ํธ๋ ์ด์์์ ์์ฑ๋ ํ์ด๋ก๋๋ฅผ ํ์ฉํ์ฌ ํธ๋ ์ด์์ ์คํฌ์ ์ฐ๊ฒฐํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ์ด ๋ฐฉ๋ฒ์ ๋ค์ด์ค๋ ์์ฒญ์์ ํค/๊ฐ ์ ์ฅ์๋ฅผ ํ์ฉํ๊ณ W3C Trace Context ๋ฐ์ดํฐ๋ฅผ ์ฐพ์ ํ, ์ฐพ์ ์ ์์ผ๋ฉด ๋ด๋ ๋ฆญ ๋ถ์ฐ ํธ๋ ์ด์ค ๋ฐ์ดํฐ๋ก ๋์ฒดํฉ๋๋ค.
๋งค๊ฐ๋ณ์
์ด๋ฆ | ์ค๋ช |
|---|---|
<ํฐ> | ํ์์. ํธ์ถ ์๋น์ค์์ ๋ถ์ฐ ์ถ์ ๋ฐ์ดํฐ๋ฅผ ์ฝ์
ํ ํค/๊ฐ ์ ์ ์ฅ์์
๋๋ค. ์ด๊ฒ์ ํธ์ถ ์๋น์ค์์ ํธ์ถ๋๋ ์๋น์ค๋ก ์ ๋ฌ๋๋ ๋ชจ๋ ๋ฉ์์ง ๊ฐ์ฒด์ ์กด์ฌํด์ผ ํ๋ฉฐ, ์ฌ์ฉ๋๋ ์ ์ก ์๋จ์ ๋ฐ๋ผ ๋ฌ๋ผ์ผ ํฉ๋๋ค. ์๋ฅผ ๋ค์ด Azure Service Bus ๋ฉ์์ง์ ๊ฒฝ์ฐ |
Func<T, ๋ฌธ์์ด, IEnumerable<๋ฌธ์์ด>> | ํ์์. ์ด์ก์ ์ฒด๋ก๋ถํฐ ์ถ์ ๋ฐ์ดํฐ๋ฅผ ์ถ์ถํ๋ ์ฌ์ฉ์ ์ ์ ํจ์์ ๋๋ค. ์๋์ ์๋ฅผ ๋ณด์ธ์. |
TransportType ์ด๊ฑฐํ | ํ์์. ์์ ํ์ด๋ก๋์ ์ ์ก์ ์ค๋ช
ํฉ๋๋ค(์: |
์ฌ์ฉ ๊ณ ๋ ค ์ฌํญ
- ๋ถ์ฐ ์ถ์ ์ ํ์ฑํํด์ผ ํฉ๋๋ค .
- ์ด API ๊ธฐ์กด ๋ผ์ด์ผ์ค ์ปจํ ์คํธ ๋ด์์๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค.
AcceptDistributedTraceHeaders์ด ํธ๋์ญ์ ์ ๋ํดInsertDistributedTraceHeaders๋๋AcceptDistributedTraceHeaders์ด(๊ฐ) ์ด๋ฏธ ํธ์ถ๋ ๊ฒฝ์ฐ ๋ฌด์๋ฉ๋๋ค.
์์
์ด API์ ์ฌ์ฉ์ ๋ณด์ฌ์ฃผ๊ธฐ ์ํด ๋น๋ํ๊ณ ์คํํ ์ ์๋ ์์ ํ ์์ ๋ ์ฌ๊ธฐ์์์ฐพ์ ์ ์์ต๋๋ค.
// Get a reference to the agent, which lets you get a reference to the current transactionIAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent();ITransaction currentTransaction = agent.CurrentTransaction;
// In this example, we are using Azure Service Bus. The `ServiceBusMessage` type has an `ApplicationProperties` property for custom key/value pairs.
// Recieve an incoming message. Assume that `receiver` is a previously-configured `ServiceBusReceiver`ServiceBusReceivedMessage message = await receiver.ReceiveMessageAsync();
// Define the getter Func. The `ApplicationProperties` dictionary is the trace data carrier.IEnumerable<string> Getter(IDictionary<string, object> carrier, string key){ var data = new List<string>(); if (carrier == null) { return data; } object value; if (applicationProperties.TryGetValue(key, out value)) { if (value != null) { data.Add(value.ToString()); } } return data;}
// Call the API to accept the distributed tracing data from the messagecurrentTransaction.AcceptDistributedTraceHeaders(message.ApplicationProperties, Getter, TransportType.Queue);ํต์ฌ๋ก
ITransaction AddCustomAttribute(string key, object value)์์ฑ ํ์์ผ๋ก ํ์ฌ ํธ๋์ญ์ ์ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ํ ์ปจํ ์คํธ ์ ๋ณด๋ฅผ ์ถ๊ฐํฉ๋๋ค.
์ด ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ ค๋ฉด .NET ์์ด์ ํธ ๋ฒ์ ๋ฐ .NET ์์ด์ ํธ API ๋ฒ์ 8.24.244.0 ์ด์์ด ํ์ํฉ๋๋ค. ๋ ์ด์ ์ฌ์ฉ๋์ง ์๋ AddCustomParameter ์ ๋์ฒดํ์ต๋๋ค.
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ | ๋ณด๊ณ ๋๋ ์ ๋ณด๋ฅผ ์๋ณํฉ๋๋ค. ์ด๋ฆ์ผ๋ก๋ ์๋ ค์ ธ ์์ต๋๋ค.
|
๋ฌผ์ฒด | ๋ณด๊ณ ๋๋ ๊ฐ์ ๋๋ค. ์ฐธ๊ณ : |
.NET ์ ํ | ๊ฐ์น๊ฐ ํํ๋๋ ๋ฐฉ์ |
|---|---|
| ์ ๋ถ ๊ฐ์ผ๋ก. |
| 10์ง์ ๊ธฐ๋ฐ ์ซ์์ ๋๋ค. |
| 255๋ฐ์ดํธ ์ดํ์ ์๋ฆฐ ๋ฌธ์์ด์ ๋๋ค. ๋น ๋ฌธ์์ด์ด ์ง์๋ฉ๋๋ค. |
| ์ฐธ ๋๋ ๊ฑฐ์ง. |
| ํ์ค ์๊ฐ๋ ์ ๋ณด๋ฅผ ํฌํจํ์ฌ ISO-8601 ํ์์ ๋ฐ๋ฅด๋ ๋ฌธ์์ด ํํ: ์์: |
| ์ด ์๋ฅผ ๋ํ๋ด๋ 10์ง์ ๊ธฐ๋ฐ ์ซ์์ ๋๋ค. |
๋ค๋ฅธ ๋ชจ๋ ๊ฒ |
|
๋ณด๊ณ
ํ์ฌ ํธ๋์ญ์ ์ ๋ํ ์ฐธ์กฐ์ ๋๋ค.
์ฌ์ฉ ๊ณ ๋ ค ์ฌํญ
์ง์๋๋ ๋ฐ์ดํฐ ์ ํ์ ๋ํ ์์ธํ ๋ด์ฉ์ ์ฌ์ฉ์ ์ ์ ์์ฑ์ ์ฐธ์กฐํ์ธ์.
์์
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent();ITransaction transaction = agent.CurrentTransaction;transaction.AddCustomAttribute("customerName","Bob Smith") .AddCustomAttribute("currentAge",31) .AddCustomAttribute("birthday", new DateTime(2000, 02, 14)) .AddCustomAttribute("waitTime", TimeSpan.FromMilliseconds(93842));ํ์ฌ ์คํ ์ค์ธ ๋ฒ์ ์ ๋ํ ์ก์ธ์ค๋ฅผ ์ ๊ณตํ์ฌ ๋ด๋ ๋ฆญ API ๋ด์์ ๋ฒ์๋ณ ๋ฉ์๋๋ฅผ ์ฌ์ฉํ ์ ์๋๋ก ํฉ๋๋ค.
์์
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent(); ITransaction transaction = agent.CurrentTransaction; ISpan currentSpan = transaction.CurrentSpan;ํต์ฌ๋ก
ITransaction SetUserId(string userId)์ฌ์ฉ์ ID๋ฅผ ํ์ฌ ํธ๋์ญ์ ๊ณผ ์ฐ๊ฒฐํฉ๋๋ค.
์ด ๋ฐฉ๋ฒ์๋ .NET ์์ด์ ํธ ๋ฐ .NET ์์ด์ ํธ API ๋ฒ์ 10.9.0 ์ด์์ด ํ์ํฉ๋๋ค.
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ | ์ด ๊ฑฐ๋์ ๊ด๋ จ๋ ์ฌ์ฉ์ ID์ ๋๋ค.
|
์์
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent(); ITransaction transaction = agent.CurrentTransaction; transaction.SetUserId("BobSmith123");ํต์ฌ๋ก
SegmentWrapper? RecordDatastoreSegment(string vendor, string model, string operation, string? commandText = null, string? host = null, string? portPathOrID = null, string? databaseName = null).NET ์์ด์ ํธ๊ฐ ์ง์๋๋ ๋ฐ์ดํฐ ์ ์ฅ์์ ๋์ผํ ๋ฐฉ์์ผ๋ก ์ง์๋์ง ์๋ ๋ฐ์ดํฐ ์คํ ์ด๋ฅผ ์๋์ผ๋ก ์ ๋ก๋ํ ์ ์์ต๋๋ค.
์ด ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ ค๋ฉด .NET ์์ด์ ํธ์ .NET ์์ด์ ํธ API ๋ฒ์ 10.22.0 ์ด์์ด ํ์ํฉ๋๋ค.
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ | MySQL, MSSQL, MongoDB์ ๊ฐ์ ๋ฐ์ดํฐ์คํ ์ด ๊ณต๊ธ์ ์ฒด ์ด๋ฆ์ ๋๋ค. |
๋ | ๋น๊ด๊ณํ์์ ํ ์ด๋ธ ์ด๋ฆ ๋๋ ์ด์ ์ ์ฌํ ๋ฐ์ดํฐ์คํ ์ด. |
๋ | SQL ๋ฐ์ดํฐ๋ฒ ์ด์ค์ "SELECT" ๋๋ "UPDATE"์ ๊ฐ์ ์ํ๋๋ ์์ ์ ๋๋ค. |
๋? | ์ ํ ๊ณผ๋ชฉ. ์ฟผ๋ฆฌ ๋๋ ๋น๊ด๊ณํ ๋ฐ์ดํฐ์คํ ์ด์ ์ ์ฌํ ์ค๋ช ์์ ๋๋ค. |
๋? | ์ ํ ๊ณผ๋ชฉ. ๋ฐ์ดํฐ์คํ ์ด๋ฅผ ํธ์คํ ํ๋ ์๋ฒ์ ๋๋ค. |
๋? | ์ ํ ๊ณผ๋ชฉ. ๋ฐ์ดํฐ์คํ ์ด๋ฅผ ์๋ณํ๋ ๋ฐ ๋์์ด ๋๋๋ก ํธ์คํธ์ ์์ ์ด๋ฃจ๋ ํฌํธ, ๊ฒฝ๋ก ๋๋ ๊ธฐํ ์ ์ธ. |
๋? | ์ ํ ๊ณผ๋ชฉ. ๋ฐ์ดํฐ์คํ ์ด ์ด๋ฆ ๋๋ ์ด์ ์ ์ฌํ ์ ์ธ. |
๋ณด๊ณ
์ธ๊ทธ๋จผํธ๋ฅผ ์๋์ผ๋ก ์์ฑํ๊ณ ์ข ๋ฃํ๋ IDisposable ์ธ๊ทธ๋จผํธ ๋ํผ์ ๋๋ค.
์์
var transaction = NewRelic.Api.Agent.NewRelic.GetAgent().CurrentTransaction;using (transaction.RecordDatastoreSegment(vendor, model, operation, commandText, host, portPathOrID, databaseName)){ DatastoreWorker();}ํต์ฌ๋ก
Public interface ISpanNew Relic API์ ๋ฒ์๋ณ ๋ฉ์๋์ ๋ํ ์ก์ธ์ค๋ฅผ ์ ๊ณตํฉ๋๋ค.
์ค๋ช
New Relic .NET ์์ด์ ํธ API์ ๋ฒ์๋ณ ๋ฉ์๋์ ๋ํ ์ก์ธ์ค๋ฅผ ์ ๊ณตํฉ๋๋ค. ISpan ์ ๋ํ ์ฐธ์กฐ๋ฅผ ์ป์ผ๋ ค๋ฉด ๋ค์์ ์ฌ์ฉํ์ญ์์ค.
IAgent์CurrentSpan์์ฑ(๊ถ์ฅ)ITransaction์CurrentSpan์์ฑ์ ๋๋ค.
์ด ์น์
์๋ ISpan ๋ฉ์๋์ ๋ํ ์ค๋ช
๊ณผ ๋งค๊ฐ๋ณ์๊ฐ ํฌํจ๋์ด ์์ต๋๋ค.
์ด๋ฆ | ์ค๋ช |
|---|---|
| ์์ฑ ํํ๋ก ์ ํ๋ฆฌ์ผ์ด์ ์ ์ปจํ ์คํธ ์ ๋ณด๋ฅผ ํ์ฌ span์ ์ถ๊ฐํฉ๋๋ค(์์ธํ ๋ด์ฉ์ ์๋ ์ฐธ์กฐ). |
| ๋ด๋ ๋ฆญ์ผ๋ก ๋ณด๊ณ ๋ ํ์ฌ ์คํฌ/์ธ๊ทธ๋จผํธ/๋ฉํธ๋ฆญ์ ์ด๋ฆ์ ๋ณ๊ฒฝํฉ๋๋ค(์์ธํ ๋ด์ฉ์ ์๋ ์ฐธ์กฐ). |
์์ฑ ํ์์ผ๋ก ํ์ฌ ๋ฒ์์ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ํ ์ปจํ ์คํธ ์ ๋ณด๋ฅผ ์ถ๊ฐํฉ๋๋ค.
์ด ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ ค๋ฉด .NET ์์ด์ ํธ ๋ฒ์ ๋ฐ .NET ์์ด์ ํธ API ๋ฒ์ 8.25 ์ด์์ด ํ์ํฉ๋๋ค.
ํต์ฌ๋ก
ISpan AddCustomAttribute(string key, object value)๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
๋ | ๋ณด๊ณ ๋๋ ์ ๋ณด๋ฅผ ์๋ณํฉ๋๋ค. ์ด๋ฆ์ผ๋ก๋ ์๋ ค์ ธ ์์ต๋๋ค.
| ||||||||||||||||
๋ฌผ์ฒด | ๋ณด๊ณ ๋๋ ๊ฐ์ ๋๋ค. ์ฐธ๊ณ :
|
๋ณด๊ณ
ํ์ฌ ๋ฒ์์ ๋ํ ์ฐธ์กฐ์ ๋๋ค.
์ฌ์ฉ ๊ณ ๋ ค ์ฌํญ
์ง์๋๋ ๋ฐ์ดํฐ ์ ํ์ ๋ํ ์์ธํ ๋ด์ฉ์ ์ฌ์ฉ์ ์ ์ ์์ฑ ๊ฐ์ด๋ ๋ฅผ ์ฐธ์กฐํ์ญ์์ค.
์
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent(); ISpan currentSpan = agent.CurrentSpan;
currentSpan .AddCustomAttribute("customerName","Bob Smith") .AddCustomAttribute("currentAge",31) .AddCustomAttribute("birthday", new DateTime(2000, 02, 14)) .AddCustomAttribute("waitTime", TimeSpan.FromMilliseconds(93842));New Relic์ ๋ณด๊ณ ๋ ํ์ฌ ์ธ๊ทธ๋จผํธ/์คํฌ์ ์ด๋ฆ์ ๋ณ๊ฒฝํฉ๋๋ค. ์ฌ์ฉ์ ์ง์ ๊ณ์ธก์ผ๋ก ์ธํ ์ธ๊ทธ๋จผํธ/์คํฌ์ ๊ฒฝ์ฐ New Relic์ ๋ณด๊ณ ๋ ๋ฉํธ๋ฆญ ์ด๋ฆ๋ ๋ณ๊ฒฝ๋ฉ๋๋ค.
์ด ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ ค๋ฉด .NET ์์ด์ ํธ ๋ฒ์ ๋ฐ .NET ์์ด์ ํธ API ๋ฒ์ 10.1.0์ด ํ์ํฉ๋๋ค. ๋๋ ๋ ๋๊ฒ.
ํต์ฌ๋ก
ISpan SetName(string name)๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ | ๋ฒ์/์ธ๊ทธ๋จผํธ์ ์ ์ด๋ฆ์ ๋๋ค. |
๋ณด๊ณ
ํ์ฌ ๋ฒ์์ ๋ํ ์ฐธ์กฐ์ ๋๋ค.
์
[Trace]public void MyTracedMethod(){ IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent(); ISpan currentSpan = agent.CurrentSpan;
currentSpan.SetName("MyCustomName");}ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.IgnoreApdex()Apdex๋ฅผ ๊ณ์ฐํ ๋ ํ์ฌ ํธ๋์ญ์ ์ ๋ฌด์ํฉ๋๋ค.
์๊ตฌ ์ฌํญ
๋ชจ๋ ์์ด์ ํธ ๋ฒ์ ๊ณผ ํธํ๋ฉ๋๋ค.
์ค๋ช
Apdex ์ ์ ๋ฅผ ๊ณ์ฐํ ๋ ํ์ฌ ํธ๋์ญ์ ์ ๋ฌด์ํฉ๋๋ค. ์ด๋ Apdex ์ ์๋ฅผ ์๊ณกํ ์ ์๋ ๋งค์ฐ ์งง๊ฑฐ๋ ๋งค์ฐ ๊ธด ํธ๋์ญ์ (์: ํ์ผ ๋ค์ด๋ก๋)์ด ์๋ ๊ฒฝ์ฐ์ ์ ์ฉํฉ๋๋ค.
์
NewRelic.Api.Agent.NewRelic.IgnoreApdex();ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.IgnoreTransaction()ํ์ฌ ํธ๋์ญ์ ์ ๊ณ์ธกํ์ง ๋ง์ญ์์ค.
์๊ตฌ ์ฌํญ
- ๋ชจ๋ ์์ด์ ํธ ๋ฒ์ ๊ณผ ํธํ๋ฉ๋๋ค.
- ํธ๋์ญ์ ๋ด์์ ํธ์ถ๋์ด์ผ ํฉ๋๋ค.
์ค๋ช
ํ์ฌ ํธ๋์ญ์ ์ ๋ฌด์ํฉ๋๋ค.
ํ
์ฌ์ฉ์ ์ ์ ๊ณ์ธก XML ํ์ผ์ ํตํด ํธ๋์ญ์ ์ ๋ฌด์ํ ์๋ ์์ต๋๋ค.
์
NewRelic.Api.Agent.NewRelic.IgnoreTransaction();ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.IncrementCounter(string $metric_name)๋ง์ถค ์ธก์ ํญ๋ชฉ์ ๋ํ ์นด์ดํฐ๋ฅผ 1์ฉ ์ฆ๊ฐ์ํต๋๋ค.
์๊ตฌ ์ฌํญ
- ๋ชจ๋ ์์ด์ ํธ ๋ฒ์ ๊ณผ ํธํ๋ฉ๋๋ค.
- ๋ชจ๋ ์ฑ ์ ํ๊ณผ ํธํ๋ฉ๋๋ค.
์ค๋ช
์ฌ์ฉ์ ์ ์ ์งํ ์ ์นด์ดํฐ๋ฅผ 1์ฉ ์ฆ๊ฐ์ํต๋๋ค. ์ด๋ฌํ ์ฌ์ฉ์ ์ ์ ์งํ๋ฅผ ๋ณด๋ ค๋ฉด ์ฟผ๋ฆฌ ๋น๋๋ฅผ ์ฌ์ฉํ์ฌ ์งํ๋ฅผ ๊ฒ์ํ๊ณ ์ฌ์ฉ์ ์ ์ ๊ฐ๋ฅํ ์ฐจํธ๋ฅผ ๋ง๋์ธ์. RecordMetric() ๋ฐ RecordResponseTimeMetric() ๋ ์ฐธ์กฐํ์ธ์.
์ค์
๋ง์ถค ์ธก์ ํญ๋ชฉ์ ๋ง๋ค ๋ Custom/ ๋ก ์ด๋ฆ์ ์์ํฉ๋๋ค(์: Custom/MyMetric ). ์ด๋ฆ ์ง์ ์ ๋ํ ์์ธํ ๋ด์ฉ์ ์ฌ์ฉ์ ์ ์ ๋ฉํธ๋ฆญ ์์ง ์ ์ฐธ์กฐํ์ญ์์ค.
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ | ํ์์. ์ฆ๊ฐ์ํฌ ๋ฉํธ๋ฆญ์ ์ด๋ฆ์ ๋๋ค. |
์
NewRelic.Api.Agent.NewRelic.IncrementCounter("Custom/ExampleMetric");๊ณผ๋ถํ
์ค๋ฅ๋ฅผ ํ์ธํ๊ณ ์ ํ์ ์ฌ์ฉ์ ์ ์ ์์ฑ๊ณผ ํจ๊ป New Relic์ ๋ณด๊ณ ํฉ๋๋ค.
NewRelic.Api.Agent.NewRelic.NoticeError(Exception $exception);NewRelic.Api.Agent.NewRelic.NoticeError(Exception $exception, IDictionary<TKey, TValue> $attributes);NewRelic.Api.Agent.NewRelic.NoticeError(string $error_message, IDictionary<TKey, TValue> $attributes);NewRelic.Api.Agent.NewRelic.NoticeError(string $error_message, IDictionary<TKey, TValue> $attributes, bool $is_expected);์๊ตฌ ์ฌํญ
์ด API ํธ์ถ์ ๋ค์๊ณผ ํธํ๋ฉ๋๋ค.
- ๋ชจ๋ ์์ด์ ํธ ๋ฒ์
- ๋ชจ๋ ์ฑ ์ ํ
์ค๋ช
์ค๋ฅ๋ฅผ ํ์ธํ๊ณ ์ ํ์ ์ฌ์ฉ์ ์ง์ ์์ฑ๊ณผ ํจ๊ป New Relic์ ๋ณด๊ณ ํฉ๋๋ค. ๊ฐ ํธ๋์ญ์
์ ๋ํด ์์ด์ ํธ๋ NoticeError() ์ ๋ํ ์ฒซ ๋ฒ์งธ ํธ์ถ์ ์์ธ ๋ฐ ์์ฑ๋ง ์ ์งํฉ๋๋ค. ์ค์ ์์ธ๋ฅผ ์ ๋ฌํ๊ฑฐ๋ ๋ฌธ์์ด์ ์ ๋ฌํ์ฌ ์์์ ์ค๋ฅ ๋ฉ์์ง๋ฅผ ์บก์ฒํ ์ ์์ต๋๋ค.
์ด ๋ฉ์๋๊ฐ ํธ๋์ญ์
๋ด์์ ํธ์ถ๋๋ฉด ์์ด์ ํธ๋ ์์ ํธ๋์ญ์
๋ด์์ ์์ธ๋ฅผ ๋ณด๊ณ ํฉ๋๋ค. ํ๋ก์ธ์ ์ธ๋ถ์์ ํธ์ถ๋๋ ๊ฒฝ์ฐ ์์ด์ ํธ๋ ์ค๋ฅ ํธ๋ ์ด์ค๋ฅผ ์์ฑํ๊ณ ๋ด๋ ๋ฆญ UI ์์ ์ค๋ฅ๋ฅผ NewRelic.Api.Agent.NoticeError API ํธ์ถ๋ก ๋ถ๋ฅํฉ๋๋ค. ํธ๋์ญ์
์ธ๋ถ์์ ํธ์ถ๋๋ ๊ฒฝ์ฐ NoticeError() ํธ์ถ์ ์ ํ๋ฆฌ์ผ์ด์
์ ์ค๋ฅ์จ์ ์ํฅ์ ๋ฏธ์น์ง ์์ต๋๋ค.
์์ด์ ํธ๋ ํธ๋ ์ด์ค ์ค๋ฅ์๋ง ์์ฑ์ ์ถ๊ฐํฉ๋๋ค. ๋ด๋ ๋ฆญ์ผ๋ก๋ ๋ณด๋ด์ง ์์ต๋๋ค. ์์ธํ ๋ด์ฉ์ AddCustomAttribute() ์ฐธ์กฐํ์ธ์.
NoticeError() ์ ์์ธ๋ฅผ ์ ๋ฌํ ๋ Microsoft์ Exception.GetBaseException() API๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ์ฅ ์์ชฝ์ ์์ธ๋ฅผ ํ์ธํฉ๋๋ค. ๊ฐ์ฅ ์์ชฝ์ ์์ธ๋ ์ค๋ฅ์ ๊ทผ๋ณธ ์์ธ์ ๋ํ๋ด๋ฉฐ APM์ ํ์๋ฉ๋๋ค. ์ต์์ ์์ธ์ ์ ์ฒด ์คํ ์ถ์ ์ด ๋ณด๊ณ ๋๋ฉฐ, ์ด๋ฅผ ํตํด ๊ด๋ จ ์ปจํ
์คํธ์ ์คํ ์ธ๋ถ ์ ๋ณด๊ฐ ์ ๊ณต๋ฉ๋๋ค. ์ด ์ ๊ทผ ๋ฐฉ์์ ์ ํ๋ฆฌ์ผ์ด์
์ ์ฒด์์ ์ค๋ฅ๊ฐ ์ ํ๋๋ ๋ฐฉ์์ ๋ํ ์์ ํ ์ปจํ
์คํธ๋ฅผ ๋ณด์กดํ๋ ๋์์ ๊ธฐ๋ณธ ์์ธ์์ ๊ฐ์ฅ ๊ตฌ์ฒด์ ์ธ ์ค๋ฅ ์ ๋ณด๋ฅผ ์ ๊ณตํฉ๋๋ค.
์ด API๋ก ๋ณด๊ณ ๋ ์ค๋ฅ๋ ์์ด์ ํธ ๊ตฌ์ฑ์์ ๋ฌด์ํ๋๋ก ๊ตฌ์ฑ๋ HTTP ์ํ ์ฝ๋(์: 404 )๋ฅผ ์ด๋ํ๋ ํธ๋์ญ์
๋ด์์ ๋ณด๊ณ ๋ ๋ ์ฌ์ ํ New Relic์ผ๋ก ์ ์ก๋ฉ๋๋ค. ์์ธํ ๋ด์ฉ ์ APM์ ์ค๋ฅ ๊ด๋ฆฌ ์ ๋ํ ์ค๋ช
์๋ฅผ ์ฐธ์กฐํ์ญ์์ค.
์ด ํธ์ถ์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ์๋ฅผ ๋ณด๋ ค๋ฉด ์๋ ์น์ ์ ๊ฒํ ํ์ธ์.
NewRelic.Api.Agent.NewRelic.NoticeError(Exception $exception)๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
์์ธ | ํ์์. ๊ณ์ธกํ๋ ค๋ |
NewRelic.Api.Agent.NewRelic.NoticeError(Exception $exception, IDictionary<TKey, TValue> $attributes)๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
์์ธ | ํ์์. ๊ณ์ธกํ๋ ค๋ |
IDictionary<TKey, TValue> | ์ค๋ฅ ๋ฉ์์ง์ ์ฃผ์์ ๋ฌ๊ธฐ ์ํด ์์ฑ์ ํค/๊ฐ ์์ ์ง์ ํ์ญ์์ค. |
NewRelic.Api.Agent.NewRelic.NoticeError(string $error_message, IDictionary<TKey, TValue> $attributes)๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ | ํ์์. ์์ธ์ธ ๊ฒ์ฒ๋ผ ๋ด๋ ๋ฆญ์ ๋ณด๊ณ ํ ๋ฌธ์์ด์ ์ง์ ํ์ธ์. ์ด ๋ฉ์๋๋ error ์ด๋ฒคํธ์ error Traces ๋ฅผ ๋ชจ๋ ์์ฑํฉ๋๋ค. ์ค๋ฅ ์ด๋ฒคํธ์๋ ์ฒ์ 1023์๋ง ์ ์ง๋๋ ๋ฐ๋ฉด errorTrace๋ ์ ์ฒด ๋ฉ์์ง๋ฅผ ์ ์งํฉ๋๋ค. |
IDictionary<TKey, TValue> | ํ์(null์ผ ์ ์์). ์ค๋ฅ ๋ฉ์์ง์ ์ฃผ์์ ๋ฌ๊ธฐ ์ํด ์์ฑ์ ํค/๊ฐ ์์ ์ง์ ํ์ญ์์ค. |
NewRelic.Api.Agent.NewRelic.NoticeError(string $error_message, IDictionary<TKey, TValue> $attributes, bool $is_expected)๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ | ํ์์. ์์ธ์ธ ๊ฒ์ฒ๋ผ ๋ด๋ ๋ฆญ์ ๋ณด๊ณ ํ ๋ฌธ์์ด์ ์ง์ ํ์ธ์. ์ด ๋ฉ์๋๋ error ์ด๋ฒคํธ์ error Traces ๋ฅผ ๋ชจ๋ ์์ฑํฉ๋๋ค. ์ค๋ฅ ์ด๋ฒคํธ์๋ ์ฒ์ 1023์๋ง ์ ์ง๋๋ ๋ฐ๋ฉด errorTrace๋ ์ ์ฒด ๋ฉ์์ง๋ฅผ ์ ์งํฉ๋๋ค. |
IDictionary<TKey, TValue> | ํ์(null์ผ ์ ์์). ์ค๋ฅ ๋ฉ์์ง์ ์ฃผ์์ ๋ฌ๊ธฐ ์ํด ์์ฑ์ ํค/๊ฐ ์์ ์ง์ ํ์ญ์์ค. |
๋ถ์ธ | Apdex ์ ์ ๋ฐ ์ค๋ฅ์จ์ ์ํฅ์ ๋ฏธ์น์ง ์๋๋ก ์ค๋ฅ๋ฅผ ์์๋๋ก ํ์ํฉ๋๋ค. |
์
์ฌ์ฉ์ ์ ์ ์์ฑ ์์ด ์์ธ ์ ๋ฌ
try{ string ImNotABool = "43"; bool.Parse(ImNotABool);}catch (Exception ex){ NewRelic.Api.Agent.NewRelic.NoticeError(ex);}์ฌ์ฉ์ ์ ์ ์์ฑ์ผ๋ก ์์ธ ์ ๋ฌ
try{ string ImNotABool = "43"; bool.Parse(ImNotABool);}catch (Exception ex){ var errorAttributes = new Dictionary<string, string>() {{"foo", "bar"},{"baz", "luhr"}}; NewRelic.Api.Agent.NewRelic.NoticeError(ex, errorAttributes);}์ฌ์ฉ์ ์ ์ ์์ฑ์ด ์๋ ์ค๋ฅ ๋ฉ์์ง ๋ฌธ์์ด ์ ๋ฌ
try{ string ImNotABool = "43"; bool.Parse(ImNotABool);}catch (Exception ex){ var errorAttributes = new Dictionary<string, string>{{"foo", "bar"},{"baz", "luhr"}}; NewRelic.Api.Agent.NewRelic.NoticeError("String error message", errorAttributes);}์ฌ์ฉ์ ์ ์ ์์ฑ ์์ด ์ค๋ฅ ๋ฉ์์ง ๋ฌธ์์ด ์ ๋ฌ
try{ string ImNotABool = "43"; bool.Parse(ImNotABool);}catch (Exception ex){ NewRelic.Api.Agent.NewRelic.NoticeError("String error message", null);}์ค๋ฅ ๋ฉ์์ง ๋ฌธ์์ด์ ์ ๋ฌํ๊ณ ์์๋๋ก ํ์ํ์ญ์์ค.
try{ string ImNotABool = "43"; bool.Parse(ImNotABool);}catch (Exception ex){ NewRelic.Api.Agent.NewRelic.NoticeError("String error message", null, true);}ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.RecordCustomEvent(string eventType, IEnumerable<string, object> attributeValues)์ฃผ์ด์ง ์ด๋ฆ๊ณผ ์์ฑ์ผ๋ก ์ฌ์ฉ์ ์ ์ ์ด๋ฒคํธ๋ฅผ ๊ธฐ๋กํฉ๋๋ค.
์๊ตฌ ์ฌํญ
- ๋ชจ๋ ์์ด์ ํธ ๋ฒ์ ๊ณผ ํธํ๋ฉ๋๋ค.
- ๋ชจ๋ ์ฑ ์ ํ๊ณผ ํธํ๋ฉ๋๋ค.
์ค๋ช
์ฟผ๋ฆฌ ๋น๋ ์์ ์ฟผ๋ฆฌํ ์ ์๋ ์ง์ ๋ ์ด๋ฆ๊ณผ ์์ฑ์ผ๋ก ์ฌ์ฉ์ ์ง์ ์ด๋ฒคํธ ๋ฅผ ๊ธฐ๋กํฉ๋๋ค. ์ด๋ฒคํธ๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ๊ธฐ๋ก๋๊ณ ์๋์ง ํ์ธํ๋ ค๋ฉด๋์๋ณด๋ ์์ ๋ฐ์ดํฐ๋ฅผ ์ฐพ์ต๋๋ค.
์ค์
- ๋ง์ ์ด๋ฒคํธ๋ฅผ ๋ณด๋ด๋ฉด ์์ด์ ํธ์ ๋ฉ๋ชจ๋ฆฌ ์ค๋ฒํค๋๊ฐ ์ฆ๊ฐํ ์ ์์ต๋๋ค.
- ๋ํ, 1MB(10^6๋ฐ์ดํธ) ์ด์์ ๊ฒ์๋ฌผ์ ์ต๋ ์ด๋ฒคํธ ์์ ๊ด๊ณ์์ด ๊ธฐ๋ก๋์ง ์์ต๋๋ค.
- ์ฌ์ฉ์ ์ ์ ๋์๋ณด๋๋ 64๊ฐ์ ์์ฑ์ผ๋ก ์ ํ๋ฉ๋๋ค.
- ์ฌ์ฉ์ ์ ์ ์์ฑ ๊ฐ์ด ์ฒ๋ฆฌ๋๋ ๋ฐฉ๋ฒ์ ๋ํ ์์ธํ ๋ด์ฉ์ ์ฌ์ฉ์ ์ ์ ์์ฑ ๊ฐ์ด๋๋ฅผ ์ฐธ์กฐํ์ญ์์ค.
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ | ํ์์. ๊ธฐ๋กํ ์ด๋ฒคํธ ์ ํ์ ์ด๋ฆ์
๋๋ค. 255์๋ฅผ ์ด๊ณผํ๋ ๋ฌธ์์ด์ ์ฌ์ฉํ๋ฉด API ํธ์ถ์ด ๋ด๋ ๋ฆญ์ผ๋ก ์ ์ก๋์ง ์์ต๋๋ค. ์ด๋ฆ์๋ ์์ซ์ ๋ฌธ์, ๋ฐ์ค |
IEnumerable<string, object> | ํ์์. ์ด๋ฒคํธ์ ์ฃผ์์ ์ถ๊ฐํ ์์ฑ์ ํค/๊ฐ ์์ ์ง์ ํ์ญ์์ค. |
์
๊ฐ์ ๊ธฐ๋ก [#record-strings]
var eventAttributes = new Dictionary<string, object>() {ย {"foo", "bar"},ย {"alice", "bob"}, ย {"age", 32}, ย {"height", 21.3f}};
NewRelic.Api.Agent.NewRelic.RecordCustomEvent("MyCustomEvent", eventAttributes);ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.RecordMetric(string $metric_name, single $metric_value)์ง์ ๋ ์ด๋ฆ์ผ๋ก ์ฌ์ฉ์ ์ง์ ๋ฉํธ๋ฆญ์ ๊ธฐ๋กํฉ๋๋ค.
์๊ตฌ ์ฌํญ
- ๋ชจ๋ ์์ด์ ํธ ๋ฒ์ ๊ณผ ํธํ๋ฉ๋๋ค.
- ๋ชจ๋ ์ฑ ์ ํ๊ณผ ํธํ๋ฉ๋๋ค.
์ค๋ช
์ฃผ์ด์ง ์ด๋ฆ์ผ๋ก ์ฌ์ฉ์ ์ ์ ์งํ๋ฅผ ๊ธฐ๋กํฉ๋๋ค. ์ด๋ฌํ ์ฌ์ฉ์ ์ ์ ์งํ๋ฅผ ๋ณด๋ ค๋ฉด ์ฟผ๋ฆฌ ๋น๋๋ฅผ ์ฌ์ฉํ์ฌ ์งํ๋ฅผ ๊ฒ์ํ๊ณ ์ฌ์ฉ์ ์ ์ ๊ฐ๋ฅํ ์ฐจํธ๋ฅผ ๋ง๋์ธ์. IncrementCounter() ๋ฐ RecordResponseTimeMetric() ๋ ์ฐธ์กฐํ์ธ์.
์ค์
๋ง์ถค ์ธก์ ํญ๋ชฉ์ ์์ฑํ ๋ ์ด๋ฆ์ Custom/ ์ผ๋ก ์์ํฉ๋๋ค(์: Custom/MyMetric ).
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ | ํ์์. ๊ธฐ๋กํ ์ธก์ ํญ๋ชฉ์ ์ด๋ฆ์ ๋๋ค. ์ฒ์ 255์๋ง ์ ์ง๋ฉ๋๋ค. |
ํ๋์ | ํ์์. ๋ฉํธ๋ฆญ์ ๋ํด ๊ธฐ๋กํ ์๋์ ๋๋ค. |
์
์ฌ๋ฆฌํ ํ๋ก์ธ์ค์ ์๋ต ์๊ฐ ๊ธฐ๋ก [#record-stopwatch]
Stopwatch stopWatch = Stopwatch.StartNew();System.Threading.Thread.Sleep(5000);stopWatch.Stop();NewRelic.Api.Agent.NewRelic.RecordMetric("Custom/DEMO_Record_Metric", stopWatch.ElapsedMilliseconds);ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.RecordResponseTimeMetric(string $metric_name, Int64 $metric_value)์ง์ ๋ ์ด๋ฆ๊ณผ ์๋ต ์๊ฐ(๋ฐ๋ฆฌ์ด)์ ์ฌ์ฉํ์ฌ ์ฌ์ฉ์ ์ง์ ๋ฉํธ๋ฆญ์ ๊ธฐ๋กํฉ๋๋ค.
์๊ตฌ ์ฌํญ
- ๋ชจ๋ ์์ด์ ํธ ๋ฒ์ ๊ณผ ํธํ๋ฉ๋๋ค.
- ๋ชจ๋ ์ฑ ์ ํ๊ณผ ํธํ๋ฉ๋๋ค.
์ค๋ช
์ฌ์ฉ์ ์ ์ ์งํ ์ ๋ํ ์๋ต ์๊ฐ์ ๋ฐ๋ฆฌ์ด ๋จ์๋ก ๊ธฐ๋กํฉ๋๋ค. ์ด๋ฌํ ์ฌ์ฉ์ ์ ์ ์งํ๋ฅผ ๋ณด๋ ค๋ฉด ์ฟผ๋ฆฌ ๋น๋๋ฅผ ์ฌ์ฉํ์ฌ ์งํ๋ฅผ ๊ฒ์ํ๊ณ ์ฌ์ฉ์ ์ ์ ๊ฐ๋ฅํ ์ฐจํธ๋ฅผ ๋ง๋์ธ์. IncrementCounter() ๋ฐ RecordMetric() ๋ ์ฐธ์กฐํ์ธ์.
์ค์
๋ง์ถค ์ธก์ ํญ๋ชฉ์ ์์ฑํ ๋ ์ด๋ฆ์ Custom/ ์ผ๋ก ์์ํฉ๋๋ค(์: Custom/MyMetric ).
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ | ํ์์. ๊ธฐ๋กํ ์๋ต ์๊ฐ ๋ฉํธ๋ฆญ์ ์ด๋ฆ์ ๋๋ค. ์ฒ์ 255์๋ง ์ ์ง๋ฉ๋๋ค. |
Int64 | ํ์์. ๊ธฐ๋กํ ์๋ต ์๊ฐ(๋ฐ๋ฆฌ์ด)์ ๋๋ค. |
์
์ฌ๋ฆฌํ ํ๋ก์ธ์ค์ ์๋ต ์๊ฐ ๊ธฐ๋ก [#record-stopwatch]
Stopwatch stopWatch = Stopwatch.StartNew();System.Threading.Thread.Sleep(5000);stopWatch.Stop();NewRelic.Api.Agent.NewRelic.RecordResponseTimeMetric("Custom/DEMO_Record_Response_Time_Metric", stopWatch.ElapsedMilliseconds);ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.SetApplicationName(string $name[, string $name_2, string $name_3])๋ฐ์ดํฐ ๋กค์ ์ ์ํ ์ฑ ์ด๋ฆ์ ์ค์ ํฉ๋๋ค.
์๊ตฌ ์ฌํญ
- ๋ชจ๋ ์์ด์ ํธ ๋ฒ์ ๊ณผ ํธํ๋ฉ๋๋ค.
- ๋ชจ๋ ์ฑ ์ ํ๊ณผ ํธํ๋ฉ๋๋ค.
์ค๋ช
New Relic์ ๋ณด๊ณ ๋ ์ ํ๋ฆฌ์ผ์ด์ ์ด๋ฆ์ ์ค์ ํฉ๋๋ค. ์ ํ๋ฆฌ์ผ์ด์ ์ด๋ฆ ์ง์ ์ ๋ํ ์์ธํ ๋ด์ฉ์ .NET ์ ํ๋ฆฌ์ผ์ด์ ์ด๋ฆ ์ง์ ์ ์ฐธ์กฐํ์ธ์ . ์ด ๋ฉ์๋๋ ์์ฉ ํ๋ก๊ทธ๋จ์ ์์ํ๋ ๋์ ํ ๋ฒ๋ง ํธ์ถ๋ฉ๋๋ค.
์ค์
์ฑ ์ด๋ฆ์ ์ ๋ฐ์ดํธํ๋ฉด ์์ด์ ํธ๊ฐ ๊ฐ์ ๋ก ๋ค์ ์์๋ฉ๋๋ค. ์์ด์ ํธ๋ ์ด์ ์ฑ ์ด๋ฆ๊ณผ ์ฐ๊ฒฐ๋ ๋ณด๊ณ ๋์ง ์์ ๋ฐ์ดํฐ๋ฅผ ์ญ์ ํฉ๋๋ค. ๊ด๋ จ ๋ฐ์ดํฐ ์์ค๋ก ์ธํด ์ ํ๋ฆฌ์ผ์ด์ ์ ์๋ช ์ฃผ๊ธฐ ๋์ ์ฑ ์ด๋ฆ์ ์ฌ๋ฌ ๋ฒ ๋ณ๊ฒฝํ๋ ๊ฒ์ ๊ถ์ฅ๋์ง ์์ต๋๋ค.
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ | ํ์์. ๊ธฐ๋ณธ ์ ํ๋ฆฌ์ผ์ด์ ์ด๋ฆ์ ๋๋ค. |
๋ | ์ ํ ๊ณผ๋ชฉ. ์ฑ ๋กค์ ์ ๋ ๋ฒ์งธ ๋ฐ ์ธ ๋ฒ์งธ ์ด๋ฆ์ ๋๋ค. ์์ธํ ๋ด์ฉ ์ ์ฑ์ ์ฌ๋ฌ ์ด๋ฆ ์ฌ์ฉ ์ ์ฐธ์กฐํ์ญ์์ค. |
์
NewRelic.Api.Agent.NewRelic.SetApplicationName("AppName1", "AppName2");ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.SetErrorGroupCallback(Func<IReadOnlyDictionary<string,object>, string> errorGroupCallback);์์ฑ ๋ฐ์ดํฐ์ IReadOnlyDictionary<string,object> ๋ฅผ ์ฌ์ฉํ๊ณ ์ค๋ฅ ๊ทธ๋ฃน ์ด๋ฆ์ ๋ฐํํ๋ ์ฝ๋ฐฑ ๋ฉ์๋๋ฅผ ์ ๊ณตํฉ๋๋ค.
์๊ตฌ ์ฌํญ
์ด API ํธ์ถ์ ๋ค์๊ณผ ํธํ๋ฉ๋๋ค.
- ์์ด์ ํธ ๋ฒ์ 10.9.0 ์ด์.
- ๋ชจ๋ ์ฑ ์ ํ
์ค๋ช
์์ด์ ํธ๊ฐ ์ค๋ฅ ์ด๋ฒคํธ ๋ฐ ์ถ์ ์ ๋ํ ์ค๋ฅ ๊ทธ๋ฃน ์ด๋ฆ์ ๊ฒฐ์ ํ๋ ๋ฐ ์ฌ์ฉํ ์ฝ๋ฐฑ ๋ฉ์๋๋ฅผ ์ค์ ํฉ๋๋ค. ์ด ์ด๋ฆ์ ์ค๋ฅ ์์ ํจ์์ ์ค๋ฅ๋ฅผ ๋ ผ๋ฆฌ ๊ทธ๋ฃน์ผ๋ก ๊ทธ๋ฃนํํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
์ฝ๋ฐฑ ๋ฉ์๋๋ IReadOnlyDictionary<string,object>์ ํ์ ๋จ์ผ ์ธ์๋ฅผ ์๋ฝํ๊ณ ๋ฌธ์์ด(์ค๋ฅ ๊ทธ๋ฃน ์ด๋ฆ)์ ๋ฐํํด์ผ ํฉ๋๋ค. IReadOnlyDictionary ์ ์ฌ์ฉ์ ์ ์ ์์ฑ์ ํฌํจํ์ฌ ๊ฐ ์ค๋ฅ ์ด๋ฒคํธ์ ์ฐ๊ด๋ ์์ฑ ๋ฐ์ดํฐ ์ ๋ชจ์์
๋๋ค.
๊ฐ ์ค๋ฅ์ ์ฌ์ฉํ ์ ์๋ ์์ฑ์ ์ ํํ ๋ชฉ๋ก์ ๋ค์์ ๋ฐ๋ผ ๋ค๋ฆ ๋๋ค.
- ์ค๋ฅ๋ฅผ ์์ฑํ ์ ํ๋ฆฌ์ผ์ด์ ์ฝ๋
- ์์ด์ ํธ ๊ตฌ์ฑ ์ค์
- ๋ง์ถค ์์ฑ์ด ์ถ๊ฐ๋์๋์ง ์ฌ๋ถ
๊ทธ๋ฌ๋ ๋ค์ ์์ฑ์ ํญ์ ์กด์ฌํด์ผ ํฉ๋๋ค.
error.classerror.messagestack_tracetransactionNamerequest.urierror.expected
์ค๋ฅ๋ฅผ ๋ ผ๋ฆฌ์ ์ค๋ฅ ๊ทธ๋ฃน์ ํ ๋นํ ์ ์๋ ๊ฒฝ์ฐ ์ค๋ฅ ๊ทธ๋ฃน ์ด๋ฆ์ ๋ํด ๋น ๋ฌธ์์ด์ด ๋ฐํ๋ ์ ์์ต๋๋ค.
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
'Func<IReadOnlyDictionary<string,object>,string>' | ์์ฑ ๋ฐ์ดํฐ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์ค๋ฅ ๊ทธ๋ฃน ์ด๋ฆ์ ๊ฒฐ์ ํ๋ ์ฝ๋ฐฑ์ ๋๋ค. |
์
์ค๋ฅ ํด๋์ค ์ด๋ฆ๋ณ๋ก ์ค๋ฅ ๊ทธ๋ฃนํ:
Func<IReadOnlyDictionary<string, object>, string> errorGroupCallback = (attributes) => { string errorGroupName = string.Empty; if (attributes.TryGetValue("error.class", out var errorClass)) { if (errorClass.ToString() == "System.ArgumentOutOfRangeException" || errorClass.ToString() == "System.ArgumentNullException") { errorGroupName = "ArgumentErrors"; } else { errorGroupName = "OtherErrors"; } } return errorGroupName;};
NewRelic.Api.Agent.NewRelic.SetErrorGroupCallback(errorGroupCallback);ํธ๋์ญ์ ์ด๋ฆ๋ณ๋ก ์ค๋ฅ ๊ทธ๋ฃนํ:
Func<IReadOnlyDictionary<string, object>, string> errorGroupCallback = (attributes) => { string errorGroupName = string.Empty; if (attributes.TryGetValue("transactionName", out var transactionName)) { if (transactionName.ToString().IndexOf("WebTransaction/MVC/Home") != -1) { errorGroupName = "HomeControllerErrors"; } else { errorGroupName = "OtherControllerErrors"; } } return errorGroupName;};
NewRelic.Api.Agent.NewRelic.SetErrorGroupCallback(errorGroupCallback);ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.SetTransactionName(string $category, string $name)ํ์ฌ ํธ๋์ญ์ ์ ์ด๋ฆ์ ์ค์ ํฉ๋๋ค.
์๊ตฌ ์ฌํญ
- ๋ชจ๋ ์์ด์ ํธ ๋ฒ์ ๊ณผ ํธํ๋ฉ๋๋ค.
- ํธ๋์ญ์ ๋ด์์ ํธ์ถ๋์ด์ผ ํฉ๋๋ค.
์ค๋ช
ํ์ฌ ํธ๋์ญ์
์ ์ ํ์ ๋ฐ๋ผ ์ด๊ธฐ ์ ๋์ฌ(WebTransaction ๋๋ OtherTransaction) ๋ค์ ์ถ๊ฐ๋ ์ฌ์ฉ์ ์ง์ ํธ๋์ญ์
์ด๋ฆ์ ์ค์ ํฉ๋๋ค. ์ด ํตํ๋ฅผ ์ฌ์ฉํ๊ธฐ ์ ์ ๋ฉํธ๋ฆญ ๊ทธ๋ฃนํ ๋ฌธ์ ์ ์๋ฏธ๋ฅผ ์ดํดํ๋์ง ํ์ธํ์ธ์.
๋์ผํ ํธ๋์ญ์ ๋ด์์ ์ด ํธ์ถ์ ์ฌ๋ฌ ๋ฒ ์ฌ์ฉํ๋ฉด ๊ฐ ํธ์ถ์ด ์ด์ ํธ์ถ์ ๋ฎ์ด์ฐ๊ณ ๋ง์ง๋ง ํธ์ถ์ด ์ด๋ฆ์ ์ค์ ํฉ๋๋ค.
์ค์
๊ฑฐ๋ ์ด๋ฆ ๋์ ๋๊ดํธ [suffix] ๋ฅผ ์ฌ์ฉํ์ง ๋ง์ญ์์ค. New Relic์ ์๋์ผ๋ก ์ด๋ฆ์์ ๊ดํธ๋ฅผ ์ ๊ฑฐํฉ๋๋ค. ๋์ ํ์ํ ๊ฒฝ์ฐ ๊ดํธ (suffix) ๋๋ ๊ธฐํ ๊ธฐํธ๋ฅผ ์ฌ์ฉํ์ญ์์ค.
๊ณ ์ ๊ฐ(์: URL, ํ์ด์ง ์ ๋ชฉ, 16์ง์ ๊ฐ, ์ธ์
ID ๋ฐ ๊ณ ์ ํ๊ฒ ์๋ณ ๊ฐ๋ฅํ ๊ฐ)์ ํ๋ก์ธ์ ์ด๋ฆ ์ง์ ์ ์ฌ์ฉํด์๋ ์ ๋ฉ๋๋ค. ๋์ , AddCustomAttribute() ํธ์ถ์ ์ฌ์ฉํ์ฌ ํด๋น ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉ์ ์ง์ ํ๋ก์ธ์๋ก ์๋์ ์ถ๊ฐํ์ธ์.
์ค์
๊ณ ์ ํ ํธ๋์ญ์ ์ด๋ฆ์ 1000๊ฐ ์ด์ ๋ง๋ค์ง ๋ง์ญ์์ค(์: ๊ฐ๋ฅํ๋ฉด URL๋ก ์ด๋ฆ์ ์ง์ ํ์ง ๋ง์ญ์์ค). ์ด๋ ๊ฒ ํ๋ฉด ์ฐจํธ์ ์ ์ฉ์ฑ์ด ๋จ์ด์ง๊ณ ๊ณ์ ๋น ๊ณ ์ ํ ๊ฑฐ๋ ์ด๋ฆ์ ์์ ๋ํด New Relic์ด ์ค์ ํ๋ ์ ํ์ ๋ถ๋ชํ ์ ์์ต๋๋ค. ๋ํ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฑ๋ฅ์ ์ ํ์ํฌ ์ ์์ต๋๋ค.
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ | ํ์์. ๋ค์ํ ์ ํ์ ํ๋ก์ธ์๋ฅผ ๊ตฌ๋ณํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋ ์ด ํ๋ก์ธ์์ ๋ฒ์ฃผ์
๋๋ค. ๊ธฐ๋ณธ๊ฐ์ |
๋ | ํ์์. ํธ๋์ญ์ ์ ์ด๋ฆ์ ๋๋ค. ์ฒ์ 255์๋ง ์ ์ง๋ฉ๋๋ค. |
์
์ด ์์ ์์๋ ASP..NET Core MVC ์ปจํธ๋กค๋ฌ์์ ์ด API ๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค. A ํ๋ก์ธ์๋ ASP..NET Core์ฉ ์์ด์ ํธ์ ์ํด ์๋์ผ๋ก ์์ฑ๋ฉ๋๋ค. License ์ด๋ฆ์ ์ฒซ ๋ฒ์งธ ๋ถ๋ถ์ ๊ณ์ํด์ WebTransaction ์ผ๋ก ์ ์ง๋ฉ๋๋ค.
public class HomeController : Controller{
public IActionResult Order(string product) {
// The commented-out API call below is probably a bad idea and will lead to a metric grouping issue (MGI) // because too many transaction names will be created. Don't do this. //NewRelic.Api.Agent.NewRelic.SetTransactionName("Other", $"ProductOrder-{product}");
// Do this instead if you want to record request-specific data about this MVC endpoint var tx = NewRelic.Api.Agent.NewRelic.GetAgent().CurrentTransaction; tx.AddCustomAttribute("productName", product);
// The default transaction name at this point will be: WebTransaction/MVC/Home/Order
// Set custom transaction name NewRelic.Api.Agent.NewRelic.SetTransactionName("Other", "OrderProduct");
// Transaction name is now: WebTransaction/Other/OrderProduct
return View(); }}์ด ์์ ๋ ์ฝ์ ์ ํ๋ฆฌ์ผ์ด์
์์ ์ด API๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค. ์์ ๋ฉ์๋์ ๋ํ ์๋๋ฅผ ์์ฑํ๋ ๋ฐ ํ์ํ [Transaction] ์ฌ์ฉ์ ๊ถํ ์์ฑ์ ์ฐธ๊ณ ํ์ธ์. License ์ด๋ฆ์ ์ฒซ ๋ฒ์งธ ๋ถ๋ถ์ ๊ณ์ํด์ OtherTransaction ๋ก ์ ์ง๋ฉ๋๋ค.
using NewRelic.Api.Agent;
namespace SetApplicationNameConsoleExample{ internal class Program { static void Main(string[] args) { Console.WriteLine("Hello, World!");
var start = DateTime.Now; while (DateTime.Now - start < TimeSpan.FromMinutes(2)) { DoSomething(); Thread.Sleep(TimeSpan.FromSeconds(5)); } }
[Transaction] // Attribute-based custom instrumentation to create a transaction for this method static void DoSomething() { Console.WriteLine("Doing something: " + Guid.NewGuid().ToString());
// Transaction name from default naming at this point is: OtherTransaction/Custom/SetApplicationNameConsoleExample.Program/DoSomething
NewRelic.Api.Agent.NewRelic.SetTransactionName("Console", "MyCustomTransactionName");
// Transaction name at this point is: OtherTransaction/Console/MyCustomTransactionName
// Note, however, that this transaction will still have a child segment (span) named "SetApplicationNameConsoleExample.Program.DoSomething" } }}ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.SetTransactionUri(Uri $uri)ํ์ฌ ํธ๋์ญ์ ์ URI๋ฅผ ์ค์ ํฉ๋๋ค.
์๊ตฌ ์ฌํญ
- ํธ๋์ญ์ ๋ด์์ ํธ์ถ๋์ด์ผ ํฉ๋๋ค.
- ์์ด์ ํธ ๋ฒ์ 6.16 ์ด์.
์ค์
์ด ๋ฐฉ๋ฒ์ Web ์์ฑ์ด true ๋ก ์ค์ ๋ Transaction ์์ฑ์ ์ฌ์ฉํ์ฌ ์์ฑ๋ ํธ๋์ญ์
๋ด์์ ์ฌ์ฉ๋ ๋๋ง ์๋ํฉ๋๋ค. ( ์์ฑ์ ํตํ ์ฌ์ฉ์ ์ ์๋ฅผ ์ฐธ์กฐํ์ธ์.) ์์ด์ ํธ๊ฐ ์๋์ผ๋ก ์ง์ํ์ง ์๋ ์ฌ์ฉ์ ์ ์ ์น ๊ธฐ๋ฐ ํ๋ ์์ํฌ์ ๋ํ ์ง์์ ์ ๊ณตํฉ๋๋ค.
์ค๋ช
ํ์ฌ ํ๋ก์ธ์์ URI๋ฅผ ์ค์ ํฉ๋๋ค. URI๋ ํ๋ก์ธ์ ํธ๋ ์ด์ค ๋ฐ ํ๋ก์ธ์ ์ด๋ฒคํธ ์ request.uri ์์ฑ์ ๋ํ๋๋ฉฐ, ํ๋ก์ธ์ ์ด๋ฆ ์ง์ ์๋ ์ํฅ์ ๋ฏธ์น ์ ์์ต๋๋ค.
๋์ผํ ํธ๋์ญ์ ๋ด์์ ์ด ํธ์ถ์ ์ฌ๋ฌ ๋ฒ ์ฌ์ฉํ๋ฉด ๊ฐ ํธ์ถ์ด ์ด์ ํธ์ถ์ ๋ฎ์ด์๋๋ค. ๋ง์ง๋ง ํธ์ถ์ URI๋ฅผ ์ค์ ํฉ๋๋ค.
์ฐธ๊ณ : ์์ด์ ํธ ๋ฒ์ 8.18๋ถํฐ request.uri ์์ฑ์ ๊ฐ์ API์ ์ ๋ฌ๋ System.Uri ๊ฐ์ฒด์ Uri.AbsolutePath ์์ฑ ๊ฐ์ผ๋ก ์ค์ ๋ฉ๋๋ค.
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
์ฐ๋ฆฌ | ์ด ํธ๋์ญ์ ์ URI์ ๋๋ค. |
์
var uri = new System.Uri("https://www.mydomain.com/path");NewRelic.Api.Agent.NewRelic.SetTransactionUri(uri);ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.SetUserParameters(string $user_value, string $account_value, string $product_value)์ฌ์ฉ์ ๊ด๋ จ ์ฌ์ฉ์ ์ ์ ์์ฑ์ ๋ง๋ญ๋๋ค. AddCustomAttribute ๋ ์ ์ฐํฉ๋๋ค.
์๊ตฌ ์ฌํญ
- ๋ชจ๋ ์์ด์ ํธ ๋ฒ์ ๊ณผ ํธํ๋ฉ๋๋ค.
- ํธ๋์ญ์ ๋ด์์ ํธ์ถ๋์ด์ผ ํฉ๋๋ค.
์ค๋ช
ํ
์ด ํธ์ถ์ ์ฌ์ฉํ๋ฉด ๊ธฐ์กด ํค์๋ง ๊ฐ์ ํ ๋นํ ์ ์์ต๋๋ค. ํค/๊ฐ ์์ ์์ฑํ๋ ๋ณด๋ค ์ ์ฐํ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ ค๋ฉด AddCustomAttribute() ์ฌ์ฉํ์ธ์.
๋ธ๋ผ์ฐ์ ํ์ด์ง ๋ณด๊ธฐ(์ฌ์ฉ์ ์ด๋ฆ, ๊ณ์ ์ด๋ฆ, ์ ํ ์ด๋ฆ)์ ์ฐ๊ฒฐํ ์ฌ์ฉ์ ๊ด๋ จ ์ฌ์ฉ์ ์ ์ ์์ฑ์์ ์ํฉ๋๋ค. ๊ฐ์ ์๋์ผ๋ก ๊ธฐ์กด ํค(user, account ๋ฐ product)์ ์ฐ๊ฒฐ๋ ๋ค์ ์์ APM ํธ๋์ญ์
์ ์ฐ๊ฒฐ๋ฉ๋๋ค. ๋ํ ์ด๋ฌํ ์์ฑ์ ๋ธ๋ผ์ฐ์ PageView ์ด๋ฒคํธ์ ์ฒจ๋ถ(๋๋ "์ ๋ฌ") ํ ์๋ ์์ต๋๋ค.
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ | ํ์(null์ผ ์ ์์). ์ด ํ์ด์ง ๋ณด๊ธฐ์ ์ฐ๊ฒฐํ ์ด๋ฆ ๋๋ ์ฌ์ฉ์ ์ด๋ฆ์ ์ง์ ํ์ญ์์ค. ์ด ๊ฐ์ |
๋ | ํ์(null์ผ ์ ์์). ์ด ํ์ด์ง ๋ณด๊ธฐ์ ์ฐ๊ฒฐํ ์ฌ์ฉ์ ๊ณ์ ์ ์ด๋ฆ์ ์ง์ ํ์ญ์์ค. ์ด ๊ฐ์ |
๋ | ํ์(null์ผ ์ ์์). ์ด ํ์ด์ง ๋ณด๊ธฐ์ ์ฐ๊ฒฐํ ์ ํ์ ์ด๋ฆ์ ์ง์ ํ์ญ์์ค. ์ด ๊ฐ์ |
์
์ธ ๊ฐ์ง ์ฌ์ฉ์ ์์ฑ ๊ธฐ๋ก
NewRelic.Api.Agent.NewRelic.SetUserParameters("MyUserName", "MyAccountName", "MyProductName");๋ ๊ฐ์ ์ฌ์ฉ์ ์์ฑ๊ณผ ํ๋์ ๋น ์์ฑ ๊ธฐ๋ก
NewRelic.Api.Agent.NewRelic.SetUserParameters("MyUserName", "", "MyProductName");ํต์ฌ๋ก
NewRelic.Api.Agent.NewRelic.StartAgent()์์ด์ ํธ๊ฐ ์์ง ์์๋์ง ์์ ๊ฒฝ์ฐ ์์ํฉ๋๋ค. ์ผ๋ฐ์ ์ผ๋ก ๋ถํ์ํฉ๋๋ค.
์๊ตฌ ์ฌํญ
- ๋ชจ๋ ์์ด์ ํธ ๋ฒ์ ๊ณผ ํธํ๋ฉ๋๋ค.
- ๋ชจ๋ ์ฑ ์ ํ๊ณผ ํธํ๋ฉ๋๋ค.
์ค๋ช
์์ง ์์๋์ง ์์ ๊ฒฝ์ฐ ์์ด์ ํธ๋ฅผ ์์ํฉ๋๋ค. autoStart ๋นํ์ฑํํ์ง ์๋ ํ ๊ณ์ธก๋ ๋ฉ์๋์ ๋๋ฌํ๋ฉด ์์ด์ ํธ๊ฐ ์๋์ผ๋ก ์์๋๋ฏ๋ก ์ผ๋ฐ์ ์ผ๋ก ์ด ํธ์ถ์ ํ์ํ์ง ์์ต๋๋ค. SetApplicationName() ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์์ด์ ํธ๋ฅผ ์์ํ๊ธฐ ์ ์ ์ฑ ์ด๋ฆ์ ์ค์ ํ๋์ง ํ์ธํ์ธ์.
ํ
์ด ๋ฉ์๋๋ syncStartup ๋๋ sendDataOnExit ํ์ฑํํ์ง ์๋ ํ ์์ด์ ํธ๋ฅผ ๋น๋๊ธฐ์์ผ๋ก ์์ํฉ๋๋ค(์ฆ, ์ฑ ์์์ ์ฐจ๋จํ์ง ์์).
์
NewRelic.Api.Agent.NewRelic.StartAgent();ํต์ฌ๋ก
NewRelic.Api.Agent.TraceMetadata;์ถ์ ์ ์ง์ํ๋ ๋ฐ ์ฌ์ฉ๋๋ ํ์ฌ ์คํ ํ๊ฒฝ์ ์์ฑ์ ๋ฐํํฉ๋๋ค.
์๊ตฌ ์ฌํญ
- ์์ด์ ํธ ๋ฒ์ 8.19 ์ด์.
- ๋ชจ๋ ์ฑ ์ ํ๊ณผ ํธํ๋ฉ๋๋ค.
- ์๋ฏธ ์๋ ๊ฐ์ ์ป์ผ๋ ค๋ฉด ๋ถ์ฐ ์ถ์ ์ ํ์ฑํํด์ผ ํฉ๋๋ค .
์ค๋ช
๋ค์ ์์ฑ์ ๋ํ ์ก์ธ์ค๋ฅผ ์ ๊ณตํฉ๋๋ค.
์์ฑ
์ด๋ฆ | ์ค๋ช |
|---|---|
| ํ์ฌ ์คํ ์ค์ธ ์ถ์ ์ ๋ํ๋ด๋ ๋ฌธ์์ด์ ๋ฐํํฉ๋๋ค. ์ถ์ ID๋ฅผ ์ฌ์ฉํ ์ ์๊ฑฐ๋ ๋ถ์ฐ ์ถ์ ์ด ๋นํ์ฑํ๋ ๊ฒฝ์ฐ ๊ฐ์ |
| ํ์ฌ ์คํ ์ค์ธ ๋ฒ์๋ฅผ ๋ํ๋ด๋ ๋ฌธ์์ด์ ๋ฐํํฉ๋๋ค. ์คํฌ ID๋ฅผ ์ฌ์ฉํ ์ ์๊ฑฐ๋ ๋ถ์ฐ ์ถ์ ์ด ๋นํ์ฑํ๋ ๊ฒฝ์ฐ ๊ฐ์ |
| ํ์ฌ ์ถ์ ์ด ํฌํจ์ ์ํด ์ํ๋ง๋ ๊ฒฝ์ฐ |
์
IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent();ITraceMetadata traceMetadata = agent.TraceMetadata;string traceId = traceMetadata.TraceId;string spanId = traceMetadata.SpanId;bool isSampled = traceMetadata.IsSampled;