]>
git.proxmox.com Git - ceph.git/blob - ceph/src/common/EventTrace.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) Intel Corporation.
9 * Author: Anjaneya Chagam <anjaneya.chagam@intel.com>
11 * This is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License version 2.1, as published by the Free Software
14 * Foundation. See file COPYING.
18 #include "common/EventTrace.h"
19 #include "common/TracepointProvider.h"
20 #include "messages/MOSDOpReply.h"
23 #define TRACEPOINT_DEFINE
24 #define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
25 #include "tracing/eventtrace.h"
26 #undef TRACEPOINT_PROBE_DYNAMIC_LINKAGE
27 #undef TRACEPOINT_DEFINE
29 #define tracepoint(...)
32 TracepointProvider::Traits
event_tracepoint_traits("libeventtrace_tp.so", "event_tracing");
33 bool EventTrace::tpinit
= false;
35 void EventTrace::init_tp(CephContext
*_ctx
)
40 if (unlikely(!tpinit
)) {
41 TracepointProvider::initialize
<event_tracepoint_traits
>(_ctx
);
46 void EventTrace::set_message_attrs(const Message
*m
, string
& oid
, string
& context
, bool incl_oid
)
48 // arg1 = oid, arg2 = message type, arg3 = source!source_addr!tid!sequence
49 if (m
&& (m
->get_type() == CEPH_MSG_OSD_OP
|| m
->get_type() == CEPH_MSG_OSD_OPREPLY
)) {
51 if (m
->get_type() == CEPH_MSG_OSD_OP
)
52 oid
= ((MOSDOp
*)m
)->get_oid().name
;
54 oid
= ((MOSDOpReply
*)m
)->get_oid().name
;
58 buf
<< m
->get_source() << "!" << m
->get_source_addr() << "!"
59 << m
->get_tid() << "!" << m
->get_seq() << "!" << m
->get_type();
64 EventTrace::EventTrace(CephContext
*_ctx
, const char *_file
, const char *_func
, int _line
) :
72 last_ts
= ceph_clock_now();
75 lsubdout(ctx
, eventtrace
, LOG_LEVEL
) << "ENTRY (" << func
<< ") " << file
<< ":" << line
<< dendl
;
76 tracepoint(eventtrace
, func_enter
, file
.c_str(), func
.c_str(), line
);
79 EventTrace::~EventTrace()
83 lsubdout(ctx
, eventtrace
, LOG_LEVEL
) << "EXIT (" << func
<< ") " << file
<< dendl
;
84 tracepoint(eventtrace
, func_exit
, file
.c_str(), func
.c_str());
87 void EventTrace::log_event_latency(const char *event
)
89 utime_t now
= ceph_clock_now();
90 double usecs
= (now
.to_nsec()-last_ts
.to_nsec())/1000;
91 OID_ELAPSED("", usecs
, event
);
95 void EventTrace::trace_oid_event(const char *oid
, const char *event
, const char *context
,
96 const char *file
, const char *func
, int line
)
98 if (unlikely(!g_ceph_context
))
100 init_tp(g_ceph_context
);
101 tracepoint(eventtrace
, oid_event
, oid
, event
, context
, file
, func
, line
);
104 void EventTrace::trace_oid_event(const Message
*m
, const char *event
, const char *file
,
105 const char *func
, int line
, bool incl_oid
)
108 set_message_attrs(m
, oid
, context
, incl_oid
);
109 trace_oid_event(oid
.c_str(), event
, context
.c_str(), file
, func
, line
);
112 void EventTrace::trace_oid_elapsed(const char *oid
, const char *event
, const char *context
,
113 double elapsed
, const char *file
, const char *func
, int line
)
115 if (unlikely(!g_ceph_context
))
117 init_tp(g_ceph_context
);
118 tracepoint(eventtrace
, oid_elapsed
, oid
, event
, context
, elapsed
, file
, func
, line
);
121 void EventTrace::trace_oid_elapsed(const Message
*m
, const char *event
, double elapsed
,
122 const char *file
, const char *func
, int line
, bool incl_oid
)
125 set_message_attrs(m
, oid
, context
, incl_oid
);
126 trace_oid_elapsed(oid
.c_str(), event
, context
.c_str(), elapsed
, file
, func
, line
);