ํต์ฌ๋ก
newrelic.agent.set_error_group_callback(callback_function(exception, transaction_data))์ด ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ฉด ์ค๋ฅ ๋ฐ์ ํธ์งํจ ๋ด์ ์ค๋ฅ ๊ทธ๋ฃน์ ํน์ ์๋ณ์(๋๋ "์ง๋ฌธ")๋ก ์ค์ ํ ์ ์์ต๋๋ค.
์๊ตฌ ์ฌํญ
Python ์์ด์ ํธ ๋ฒ์ 8.8.0 ์ด์.
์ค๋ช
์ด ์๋ํฌ์ธํธ๋ ์ค๋ฅ ๊ทธ๋ฃน์ ๋ฑ๋กํ๋ ๋ฐ ์ฌ์ฉ๋๋ ์ฝ๋ฐฑ์ด๋ผ๋ ๋จ์ผ ์
๋ ฅ์ ๋ฐ์ต๋๋ค. ์ด ์ฝ๋ฐฑ์ ๊ณ ๊ฐ์ด ์ ์ํ๋ฉฐ ์์ด์ ํธ์ notice_error API๋ฅผํธ๋ฆฌ๊ฑฐํ ์์ธ๋ฅผ ์๋ฝํด์ผ ํฉ๋๋ค. ์ด ์ค์ ์ ํด์ ํ๋ ค๋ฉด API๋ฅผ ๋ค์ ํธ์ถํ๊ณ ์ฝ๋ฐฑ์ None๋ก ์ค์ ํฉ๋๋ค.
์ ๋ํ ๋งค๊ฐ๋ณ์ set_error_group_callback
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
ํธ์ถ ๊ฐ๋ฅ ํจ์ | ํ์์. ์ ์ํ๋ ค๋ ์ฝ๋ฐฑ ํจ์์
๋๋ค. ์ค์ ์ ํด์ ํ๋ ค๋ฉด |
์ ํ๋ฆฌ์ผ์ด์ ์ธ์คํด์ค | ์ ํ ๊ณผ๋ชฉ. ์ ํ๋ฆฌ์ผ์ด์ ์ธ์คํด์ค๊ฐ ์ ๊ณต๋์ง ์์ผ๋ฉด ํจ์๋ ํ์ฑํ๋ ์ ํ๋ฆฌ์ผ์ด์ ์ธ์คํด์ค๋ฅผ ํ์ธํฉ๋๋ค. |
๊ณ ๊ฐ ์ ์ ์ฝ๋ฐฑ ํจ์์ ๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
|---|---|
๋ฐํ์ ์์ธ | ํ์์. ์ด๋ ์์ด์ ํธ์ |
์ฌ์ | ํ์์. Python ์์ด์ ํธ๊ฐ ์บก์ฒํ ํธ๋์ญ์ ๋ฐ์ดํฐ ์ฌ์ ์ ๋๋ค. |
๋ฐํ ๊ฐ
์ฑ๊ณตํ๋ฉด API๋ ์ํ๋ ์ค๋ฅ ๊ทธ๋ฃน ์ด๋ฆ์ ๋ํ๋ด๋ ๋ฌธ์์ด์ ์์ด์ ํธ ์์ฑ์ผ๋ก ์ถ๊ฐํฉ๋๋ค.
์คํจํ๋ฉด API๋ error.group.name ์์ด์ ํธ ์์ฑ์ผ๋ก ์ถ๊ฐํ์ง ์์ต๋๋ค.
์ฌ์ฉ ์
์ค๋ฅ ๊ทธ๋ฃน ์ฝ๋ฐฑ ์ค์
set_error_group_callback ์ฌ์ฉ ์:
def customer_callback(exc, data): if isinstance(exc, ValueError): return "group1"
def some_other_function(): try: raise ValueError("Oh no!") except Exception: newrelic.agent.notice_error()
def example_function(customer_callback): try: newrelic.agent.set_error_group_callback(customer_callback) some_other_function() finally: newrelic.agent.set_error_group_callback(None)